Package org.teiid.query.sql.proc

Examples of org.teiid.query.sql.proc.CommandStatement


        LoopStatement loopStmt = new LoopStatement(block, query, cursor);
       
        block = new Block();       
        block.addStatement(dStmt);
        block.addStatement(loopStmt);
        CommandStatement cmdStmt = new CommandStatement(query);
        block.addStatement(cmdStmt);
       
        CreateUpdateProcedureCommand virtualProcedureCommand = new CreateUpdateProcedureCommand();
        virtualProcedureCommand.setBlock(block);
        virtualProcedureCommand.setUpdateProcedure(false);
View Full Code Here


        String sql = "CREATE PROCEDURE BEGIN IF (x > 1) select 1; IF (x > 1) select 1; ELSE select 1; END"; //$NON-NLS-1$
        String expected = "CREATE PROCEDURE\nBEGIN\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 Object[] {new ExpressionSymbol("expr", new Constant(new Integer(1)))}))); //$NON-NLS-1$
        CommandStatement commandStmt = new CommandStatement(query);
        CompareCriteria criteria = new CompareCriteria(new ElementSymbol("x"), CompareCriteria.GT, new Constant(new Integer(1))); //$NON-NLS-1$
        Block block = new Block();
        block.addStatement(commandStmt);
        IfStatement ifStmt = new IfStatement(criteria, block);
        IfStatement ifStmt1 = (IfStatement)ifStmt.clone();
View Full Code Here

  public static final CommandStatement sample1() {
    QueryParser parser = new QueryParser();   
    try {
      Query query = (Query) parser.parseCommand("Select x from y"); //$NON-NLS-1$
      return new CommandStatement(query);
    } catch(Exception e) { return null;}
  }
View Full Code Here

  public static final CommandStatement sample2() {
    QueryParser parser = new QueryParser();   
    try {
      Update update = (Update) parser.parseCommand("UPDATE x SET x = 'y'"); //$NON-NLS-1$
      return new CommandStatement(update);
    } catch(Exception e) { return null;}
  }
View Full Code Here

  }

  // ################################## ACTUAL TESTS ################################
 
  public void testSelfEquivalence(){
    CommandStatement s1 = sample1();
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1);
  }
View Full Code Here

    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1);
  }

  public void testEquivalence(){
    CommandStatement s1 = sample1();
    CommandStatement s1a = sample1();
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1a);
  }
View Full Code Here

    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1a);
  }
 
  public void testNonEquivalence(){
    CommandStatement s1 = sample1();
    CommandStatement s2 = sample2();
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, s1, s2);
  }
View Full Code Here

        q1.setSelect(select);       
        From from = new From();
        from.addGroup(new GroupSymbol("g")); //$NON-NLS-1$
        q1.setFrom(from);
             
      CommandStatement cmdStmt =  new CommandStatement(q1);
    helpTest(cmdStmt, "SELECT x FROM g;"); //$NON-NLS-1$
    }
View Full Code Here

    }
   
    public void testCommandStatement2() {
        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
    helpTest(cmdStmt, "DELETE FROM g;"); //$NON-NLS-1$
    }
View Full Code Here

    }
   
    public void testBlock1() {
        Delete d1 = new Delete();
        d1.setGroup(new GroupSymbol("g")); //$NON-NLS-1$
      CommandStatement cmdStmt =  new CommandStatement(d1);
      AssignmentStatement assigStmt =  new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1))); //$NON-NLS-1$
      RaiseErrorStatement errStmt =  new RaiseErrorStatement(new Constant("My Error")); //$NON-NLS-1$
      Block b = new Block();
      b.addStatement(cmdStmt);
      b.addStatement(assigStmt);
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.proc.CommandStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.