001package gudusoft.gsqlparser.stmt;
002
003import gudusoft.gsqlparser.*;
004import gudusoft.gsqlparser.nodes.TCloseSqlNode;
005import gudusoft.gsqlparser.nodes.TObjectName;
006import gudusoft.gsqlparser.nodes.TParseTreeVisitor;
007
008
009/**
010 * The CLOSE statement closes a cursor or cursor variable, thereby allowing its resources to be reused.
011 */
012
013public class TCloseStmt extends TCustomSqlStatement {
014
015    public TCloseStmt(){
016        this(EDbVendor.dbvoracle);
017    }
018    public TCloseStmt(EDbVendor dbvendor){
019        super(dbvendor);
020        sqlstatementtype = ESqlStatementType.sst_closestmt;
021    }
022
023    private TObjectName cursorName = null;
024
025    /**
026     *
027     * @return The name of an open explicit cursor that was declared within the current scope.
028     */
029    public TObjectName getCursorName() {
030        return cursorName;
031    }
032
033    public void init(Object arg1)
034    {
035        cursorName = (TObjectName)arg1;
036    }
037
038    void buildsql() {
039    }
040
041    void clear() {
042    }
043
044    String getasprettytext() {
045        return "";
046    }
047
048    void iterate(TVisitorAbs pvisitor) {
049    }
050
051    public int doParseStatement(TCustomSqlStatement psql) {
052        super.doParseStatement(psql);
053        if (rootNode != null){
054            TCloseSqlNode node = (TCloseSqlNode)rootNode;
055            this.cursorName = node.getCursorName();
056        }
057        return 0;
058    }
059
060    public void accept(TParseTreeVisitor v){
061        v.preVisit(this);
062        v.postVisit(this);
063    }
064
065    public void acceptChildren(TParseTreeVisitor v){
066        v.preVisit(this);
067        v.postVisit(this);
068    }
069
070    public void setCursorName(TObjectName cursorName) {
071        this.cursorName = cursorName;
072    }
073}