final public IfStatement ifStatement(ParseInfo info) throws ParseException { IfStatement ifStmt = null; Criteria criteria = null; Statement ifStatement = null; Statement elseStatement = null; String groupID = null; String groupID2 = null; boolean not = false; jj_consume_token(IF); jj_consume_token(LPAREN); criteria = criteria(info); jj_consume_token(RPAREN); ifStatement = statement(info); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ELSE: jj_consume_token(ELSE); elseStatement = statement(info); break; default: jj_la1[43] = jj_gen; ; } ifStmt = new IfStatement(criteria, asBlock(ifStatement)); ifStmt.setElseBlock(asBlock(elseStatement)); {if (true) return ifStmt;} throw new Error("Missing return statement in function"); }
final public IfStatement ifStatement(ParseInfo info) throws ParseException { IfStatement ifStmt = null; Criteria criteria = null; Statement ifStatement = null; Statement elseStatement = null; String groupID = null; String groupID2 = null; boolean not = false; jj_consume_token(IF); jj_consume_token(LPAREN); criteria = criteria(info); jj_consume_token(RPAREN); ifStatement = statement(info); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ELSE: jj_consume_token(ELSE); elseStatement = statement(info); break; default: jj_la1[43] = jj_gen; ; } ifStmt = new IfStatement(criteria, asBlock(ifStatement)); ifStmt.setElseBlock(asBlock(elseStatement)); {if (true) return ifStmt;} throw new Error("Missing return statement in function"); }
if(ifStmt.hasElseBlock()) { Block elseBlock = rewriteBlock(ifStmt.getElseBlock()); ifStmt.setElseBlock(elseBlock);
if(ifStmt.hasElseBlock()) { Block elseBlock = rewriteBlock(ifStmt.getElseBlock()); ifStmt.setElseBlock(elseBlock);
if(ifStmt.hasElseBlock()) { Block elseBlock = rewriteBlock(ifStmt.getElseBlock()); ifStmt.setElseBlock(elseBlock);
exists.setCriteria((Criteria) Criteria.combineCriteria(crits).clone()); ifStatement.setIfBlock(new Block(new CommandStatement(update))); ifStatement.setElseBlock(new Block(new CommandStatement(newInsert)));
exists.setCriteria((Criteria) Criteria.combineCriteria(crits).clone()); ifStatement.setIfBlock(new Block(new CommandStatement(update))); ifStatement.setElseBlock(new Block(new CommandStatement(newInsert)));
exists.setCriteria((Criteria) Criteria.combineCriteria(crits).clone()); ifStatement.setIfBlock(new Block(new CommandStatement(update))); ifStatement.setElseBlock(new Block(new CommandStatement(newInsert)));
@Test public void testIfElseWithoutBeginEnd() { String sql = "CREATE VIRTUAL PROCEDURE BEGIN IF (x > 1) select 1; IF (x > 1) select 1; ELSE select 1; END"; //$NON-NLS-1$ String expected = "BEGIN\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nIF(x > 1)\nBEGIN\nSELECT 1;\nEND\nELSE\nBEGIN\nSELECT 1;\nEND\nEND"; //$NON-NLS-1$ Query query = new Query(); query.setSelect(new Select(Arrays.asList(new Constant(1)))); //$NON-NLS-1$ CommandStatement commandStmt = new CommandStatement(query); CompareCriteria criteria = new CompareCriteria(new ElementSymbol("x"), CompareCriteria.GT, new Constant(1)); //$NON-NLS-1$ Block block = new Block(); block.addStatement(commandStmt); IfStatement ifStmt = new IfStatement(criteria, block); IfStatement ifStmt1 = (IfStatement)ifStmt.clone(); Block block2 = new Block(); block2.addStatement(commandStmt); ifStmt1.setElseBlock(block2); Block block3 = new Block(); block3.addStatement(ifStmt); block3.addStatement(ifStmt1); CreateProcedureCommand command = new CreateProcedureCommand(block3); helpTest(sql, expected, command); }
ifStmt.setElseBlock(asBlock(elseStatement)); {if (true) return ifStmt;} throw new Error("Missing return statement in function");