/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public Object clone() { Block otherBlock = this.loopBlock.clone(); Command otherQuery = (Command) this.query.clone(); LoopStatement ls = new LoopStatement(otherBlock, otherQuery, this.cursorName); ls.setLabel(label); return ls; }
/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public Object clone() { Block otherBlock = this.loopBlock.clone(); Command otherQuery = (Command) this.query.clone(); LoopStatement ls = new LoopStatement(otherBlock, otherQuery, this.cursorName); ls.setLabel(label); return ls; }
/** * Deep clone statement to produce a new identical statement. * @return Deep clone */ public Object clone() { Block otherBlock = this.loopBlock.clone(); Command otherQuery = (Command) this.query.clone(); LoopStatement ls = new LoopStatement(otherBlock, otherQuery, this.cursorName); ls.setLabel(label); return ls; }
public static final LoopStatement sample1() { Block block = TestBlock.sample1(); return new LoopStatement(block, query1(), "cursor"); //$NON-NLS-1$ }
public static final LoopStatement sample2() { Block block = TestBlock.sample2(); return new LoopStatement(block, query2(), "cursor"); //$NON-NLS-1$ }
final public LoopStatement loopStatement(ParseInfo info) throws ParseException { LoopStatement loopStmt = null; String cursor = null; QueryCommand query = null; Statement stmt = null; jj_consume_token(LOOP); jj_consume_token(ON); jj_consume_token(LPAREN); query = queryExpression(info); jj_consume_token(RPAREN); jj_consume_token(AS); cursor = id(null); stmt = statement(info); loopStmt = new LoopStatement(asBlock(stmt), query, cursor); {if (true) return loopStmt;} throw new Error("Missing return statement in function"); }
final public LoopStatement loopStatement(ParseInfo info) throws ParseException { LoopStatement loopStmt = null; String cursor = null; QueryCommand query = null; Statement stmt = null; jj_consume_token(LOOP); jj_consume_token(ON); jj_consume_token(LPAREN); query = queryExpression(info); jj_consume_token(RPAREN); jj_consume_token(AS); cursor = id(null); stmt = statement(info); loopStmt = new LoopStatement(asBlock(stmt), query, cursor); {if (true) return loopStmt;} throw new Error("Missing return statement in function"); }
final public LoopStatement loopStatement(ParseInfo info) throws ParseException { LoopStatement loopStmt = null; String cursor = null; QueryCommand query = null; Statement stmt = null; jj_consume_token(LOOP); jj_consume_token(ON); jj_consume_token(LPAREN); query = queryExpression(info); jj_consume_token(RPAREN); jj_consume_token(AS); cursor = id(null); stmt = statement(info); loopStmt = new LoopStatement(asBlock(stmt), query, cursor); {if (true) return loopStmt;} throw new Error("Missing return statement in function"); }
public void testCloneNonSimpleQuery(){ Block block = TestBlock.sample1(); LoopStatement ls = new LoopStatement(block, TestSetQuery.sample1(), "cursor"); //$NON-NLS-1$ LoopStatement clone = (LoopStatement) ls.clone(); UnitTestUtil.helpTestEquivalence(0, ls, clone); }
private Command asLoopProcedure(GroupSymbol group, QueryCommand query, Statement s, GroupSymbol varGroup, int updateType) throws QueryResolverException, TeiidComponentException, TeiidProcessingException { Block b = new Block(); b.addStatement(s); CreateProcedureCommand cupc = new CreateProcedureCommand(); cupc.setUpdateType(updateType); Block parent = new Block(); parent.setAtomic(true); ElementSymbol rowsUpdated = new ElementSymbol(ProcedureReservedWords.VARIABLES+Symbol.SEPARATOR+"ROWS_UPDATED"); //$NON-NLS-1$ DeclareStatement ds = new DeclareStatement(rowsUpdated, DataTypeManager.DefaultDataTypes.INTEGER, new Constant(0)); parent.addStatement(ds); LoopStatement ls = new LoopStatement(b, query, varGroup.getName()); parent.addStatement(ls); AssignmentStatement as = new AssignmentStatement(); rowsUpdated.setType(DataTypeManager.DefaultDataClasses.INTEGER); as.setVariable(rowsUpdated); as.setExpression(new Function("+", new Expression[] {rowsUpdated, new Constant(1)})); //$NON-NLS-1$ b.addStatement(as); Query returnQuery = new Query(); returnQuery.setSelect(new Select(Arrays.asList(rowsUpdated.clone()))); parent.addStatement(new CommandStatement(returnQuery)); cupc.setBlock(parent); cupc.setVirtualGroup(group); QueryResolver.resolveCommand(cupc, metadata); return rewrite(cupc, metadata, context); }
LoopStatement loop = new LoopStatement(b, (Query)q.clone(), "x"); //$NON-NLS-1$ StoredProcedure sp = new StoredProcedure(); sp.setProcedureName("SYSAdmin.refreshMatViewRow"); //$NON-NLS-1$
LoopStatement loop = new LoopStatement(b, (Query)q.clone(), "x"); //$NON-NLS-1$ StoredProcedure sp = new StoredProcedure(); sp.setProcedureName("SYSAdmin.refreshMatViewRow"); //$NON-NLS-1$
LoopStatement loop = new LoopStatement(b, (Query)q.clone(), "x"); //$NON-NLS-1$ StoredProcedure sp = new StoredProcedure(); sp.setProcedureName("SYSAdmin.refreshMatViewRow"); //$NON-NLS-1$
q.getSelect().addSymbol(new MultipleElementSymbol()); q.setFrom(new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("#changes"))))); //$NON-NLS-1$ LoopStatement ls = new LoopStatement(b, q, varGroup.getName()); parent.addStatement(ls); AssignmentStatement as = new AssignmentStatement();
@Test public void testLoopStatement() throws Exception { GroupSymbol g = new GroupSymbol("m.g"); //$NON-NLS-1$ From from = new From(); from.addGroup(g); Select select = new Select(); ElementSymbol c1 = new ElementSymbol("c1", false); //$NON-NLS-1$ select.addSymbol(c1); select.addSymbol(new ElementSymbol("c2", false)); //$NON-NLS-1$ Query query = new Query(); query.setSelect(select); query.setFrom(from); ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ String intType = new String("integer"); //$NON-NLS-1$ Statement dStmt = new DeclareStatement(x, intType); c1 = new ElementSymbol("mycursor.c1", true); //$NON-NLS-1$ Statement assignmentStmt = new AssignmentStatement(x, c1); Block block = new Block(); block.addStatement(dStmt); block.addStatement(assignmentStmt); String cursor = "mycursor"; //$NON-NLS-1$ LoopStatement loopStmt = new LoopStatement(block, query, cursor); helpStmtTest("LOOP ON (SELECT c1, c2 FROM m.g) AS mycursor BEGIN DECLARE integer x; x=mycursor.c1; END", //$NON-NLS-1$ "LOOP ON (SELECT c1, c2 FROM m.g) AS mycursor"+"\n"+ "BEGIN"+"\n"+"DECLARE integer x;"+"\n"+"x = mycursor.c1;" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ +"\n"+"END", loopStmt); //$NON-NLS-1$ //$NON-NLS-2$ }
q.getSelect().addSymbol(new MultipleElementSymbol()); q.setFrom(new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("#changes"))))); //$NON-NLS-1$ LoopStatement ls = new LoopStatement(b, q, varGroup.getName()); parent.addStatement(ls); AssignmentStatement as = new AssignmentStatement();
LoopStatement loopStmt = new LoopStatement(block, query, cursor);
LoopStatement loopStmt = new LoopStatement(block, query, cursor);
keys.setCriteria((Criteria) ((FilteredCommand)clone).getCriteria().clone()); LoopStatement loop = new LoopStatement(b, keys, "x"); //$NON-NLS-1$ StoredProcedure sp = new StoredProcedure(); sp.setProcedureName("SYSAdmin.refreshMatViewRow"); //$NON-NLS-1$
keys.setCriteria((Criteria) ((FilteredCommand)clone).getCriteria().clone()); LoopStatement loop = new LoopStatement(b, keys, "x"); //$NON-NLS-1$ StoredProcedure sp = new StoredProcedure(); sp.setProcedureName("SYSAdmin.refreshMatViewRow"); //$NON-NLS-1$