001package gudusoft.gsqlparser.stmt;
002
003import gudusoft.gsqlparser.EDbVendor;
004import gudusoft.gsqlparser.ESqlStatementType;
005import gudusoft.gsqlparser.TVisitorAbs;
006import gudusoft.gsqlparser.TCustomSqlStatement;
007import gudusoft.gsqlparser.nodes.TDropViewSqlNode;
008import gudusoft.gsqlparser.nodes.TObjectName;
009import gudusoft.gsqlparser.nodes.TParseTreeVisitor;
010import gudusoft.gsqlparser.nodes.TObjectNameList;
011
012/**
013 * remove a view or an object view from the database.
014 */
015public class TDropViewSqlStatement extends TCustomSqlStatement {
016    public TDropViewSqlStatement(EDbVendor dbvendor) {
017        super(dbvendor);
018        sqlstatementtype = ESqlStatementType.sstdropview;
019    }
020
021    void buildsql() {
022    }
023
024    void clear() {
025    }
026
027    String getasprettytext() {
028        return "";
029    }
030
031    void iterate(TVisitorAbs pvisitor) {
032    }
033
034    public int doParseStatement(TCustomSqlStatement psql) {
035        if (rootNode == null) return -1;
036        TDropViewSqlNode dropViewNode = (TDropViewSqlNode)rootNode;
037        super.doParseStatement(psql);
038
039        this.viewName = dropViewNode.getViewName();
040        this.viewNameList = dropViewNode.getViewNameList();
041        if (this.viewNameList != null){
042           this.viewName = this.viewNameList.getObjectName(0);
043        }
044        return 0;
045    }
046
047    /**
048     *
049     * @return the name of the view to be dropped.
050     */
051    public TObjectName getViewName() {
052        return viewName;
053    }
054
055    private TObjectName viewName = null;
056
057
058
059    private TObjectNameList viewNameList = null;
060
061    /**
062     *
063     * @return list of views to be drop, used in sql server.
064     */
065    public TObjectNameList getViewNameList() {
066        return viewNameList;
067    }
068
069    public void accept(TParseTreeVisitor v){
070        v.preVisit(this);
071        v.postVisit(this);
072    }
073
074    public void acceptChildren(TParseTreeVisitor v){
075        v.preVisit(this);
076        v.postVisit(this);
077    }
078
079    public void setViewName(TObjectName viewName) {
080        this.viewName = viewName;
081    }
082
083    public void setViewNameList(TObjectNameList viewNameList) {
084        this.viewNameList = viewNameList;
085    }
086}