001package gudusoft.gsqlparser.stmt.oracle;
002
003import gudusoft.gsqlparser.*;
004import gudusoft.gsqlparser.nodes.*;
005
006/**
007 * The FORALL statement issues a series of static or dynamic DML statements, usually much faster than an equivalent FOR loop.
008 */
009
010public class TPlsqlForallStmt extends TCustomSqlStatement {
011
012    public final static int     bound_clause_kind_normal = 1;
013    public final static int     bound_clause_kind_indices_of = 2;
014    public final static int     bound_clause_kind_values_of = 3;
015
016    private TExpression lower_bound = null;
017    private TExpression upper_bound = null;
018
019    /**
020     * Used in bounds clause.
021     * @return
022     */
023    public TExpression getUpper_bound() {
024
025        return upper_bound;
026    }
027
028    /**
029     * Used in bounds clause.
030     * @return
031     */
032    public TExpression getLower_bound() {
033
034        return lower_bound;
035    }
036
037    /**
038     * 
039     * @return one of  bound_clause_kind_normal, bound_clause_kind_indices_of, bound_clause_kind_values_of.
040     */
041    public int getBound_clause_kind() {
042        return bound_clause_kind;
043    }
044
045    private int bound_clause_kind = bound_clause_kind_normal;
046
047    public TPlsqlForallStmt(){
048       this(EDbVendor.dbvoracle); 
049    }
050
051     public TPlsqlForallStmt(EDbVendor dbvendor){
052        super(dbvendor);
053        sqlstatementtype = ESqlStatementType.sstplsql_forallstmt ;
054        }
055
056    void buildsql() {
057    }
058
059    void clear() {
060    }
061
062    String getasprettytext() {
063        return "";
064    }
065
066    void iterate(TVisitorAbs pvisitor) {
067    }
068
069    private TStatementSqlNode stmtSqlNode = null;
070
071    /**
072     * 
073     * @return   A static, such as UPDATE or DELETE, or dynamic (EXECUTE IMMEDIATE) DML statement that references collection elements in the VALUES or WHERE clauses.
074     */
075    public TCustomSqlStatement getStatement() {
076        return statement;
077    }
078
079    private TCustomSqlStatement statement = null;
080
081
082    public void init(Object arg1,Object arg2)
083    {
084        this.indexName = (TObjectName)arg1;
085        stmtSqlNode = (TStatementSqlNode)arg2;
086    }
087    
088    public int doParseStatement(TCustomSqlStatement psql) {
089        super.doParseStatement(psql);
090        stmtSqlNode.doParse(this,ESqlClause.unknown);
091        this.statement = stmtSqlNode.getStmt();
092        return 0;
093    }
094
095    /**
096     *
097     * @return An undeclared identifier that names the loop index.
098     */
099    public TObjectName getIndexName() {
100        return indexName;
101    }
102
103    private TObjectName indexName = null;
104
105    public void setBoundsClause(TDummy b){
106      this.bound_clause_kind = b.int1;
107      if ((bound_clause_kind == bound_clause_kind_normal)
108      || (bound_clause_kind == bound_clause_kind_indices_of)){
109          this.lower_bound = (TExpression)b.node2;
110          this.upper_bound = (TExpression)b.node3;
111      }
112        if ((bound_clause_kind == bound_clause_kind_values_of)
113        || (bound_clause_kind == bound_clause_kind_indices_of)){
114            if (b.node1 instanceof  TObjectName) {
115                this.collectionName = (TObjectName) b.node1;
116            }else if (b.node1 instanceof  TExpression){
117                collecitonNameExpr = (TExpression)b.node1;
118            }
119        }
120    }
121
122    /**
123     *
124     * @return values of collection name/indices of collection name
125     */
126    public TObjectName getCollectionName() {
127        return collectionName;
128    }
129
130    private TObjectName collectionName = null;
131    private TExpression collecitonNameExpr = null;
132
133    public TExpression getCollecitonNameExpr() {
134        return collecitonNameExpr;
135    }
136
137    public void accept(TParseTreeVisitor v){
138        v.preVisit(this);
139
140        v.postVisit(this);
141    }
142
143    public void acceptChildren(TParseTreeVisitor v){
144        v.preVisit(this);
145        statement.acceptChildren(v);
146        v.postVisit(this);
147    }
148
149    public void setLower_bound(TExpression lower_bound) {
150        this.lower_bound = lower_bound;
151    }
152
153    public void setUpper_bound(TExpression upper_bound) {
154        this.upper_bound = upper_bound;
155    }
156
157    public void setBound_clause_kind(int bound_clause_kind) {
158        this.bound_clause_kind = bound_clause_kind;
159    }
160
161    public void setStatement(TCustomSqlStatement statement) {
162        this.statement = statement;
163    }
164
165    public void setIndexName(TObjectName indexName) {
166        this.indexName = indexName;
167    }
168
169    public void setCollectionName(TObjectName collectionName) {
170        this.collectionName = collectionName;
171    }
172
173    public void setCollecitonNameExpr(TExpression collecitonNameExpr) {
174        this.collecitonNameExpr = collecitonNameExpr;
175    }
176}