Search in sources :

Example 1 with CommandStatement

use of org.teiid.query.sql.proc.CommandStatement in project teiid by teiid.

the class TestSQLStringVisitor method testBlock1.

@Test
public void testBlock1() {
    Delete d1 = new Delete();
    // $NON-NLS-1$
    d1.setGroup(new GroupSymbol("g"));
    CommandStatement cmdStmt = new CommandStatement(d1);
    // $NON-NLS-1$
    AssignmentStatement assigStmt = new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1)));
    // $NON-NLS-1$
    RaiseStatement errStmt = new RaiseStatement(new Constant("My Error"));
    Block b = new Block();
    b.addStatement(cmdStmt);
    b.addStatement(assigStmt);
    b.addStatement(errStmt);
    // $NON-NLS-1$
    helpTest(b, "BEGIN\nDELETE FROM g;\na = 1;\nRAISE 'My Error';\nEND");
}
Also used : CommandStatement(org.teiid.query.sql.proc.CommandStatement) AssignmentStatement(org.teiid.query.sql.proc.AssignmentStatement) Block(org.teiid.query.sql.proc.Block) RaiseStatement(org.teiid.query.sql.proc.RaiseStatement) Test(org.junit.Test)

Example 2 with CommandStatement

use of org.teiid.query.sql.proc.CommandStatement in project teiid by teiid.

the class TestSQLStringVisitor method testCreateUpdateProcedure1.

@Test
public void testCreateUpdateProcedure1() {
    Delete d1 = new Delete();
    // $NON-NLS-1$
    d1.setGroup(new GroupSymbol("g"));
    CommandStatement cmdStmt = new CommandStatement(d1);
    // $NON-NLS-1$
    AssignmentStatement assigStmt = new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1)));
    // $NON-NLS-1$
    RaiseStatement errStmt = new RaiseStatement(new Constant("My Error"));
    Block b = new Block();
    b.addStatement(cmdStmt);
    b.addStatement(assigStmt);
    b.addStatement(errStmt);
    CreateProcedureCommand cup = new CreateProcedureCommand(b);
    // $NON-NLS-1$
    helpTest(cup, "BEGIN\nDELETE FROM g;\na = 1;\nRAISE 'My Error';\nEND");
}
Also used : CommandStatement(org.teiid.query.sql.proc.CommandStatement) CreateProcedureCommand(org.teiid.query.sql.proc.CreateProcedureCommand) AssignmentStatement(org.teiid.query.sql.proc.AssignmentStatement) Block(org.teiid.query.sql.proc.Block) RaiseStatement(org.teiid.query.sql.proc.RaiseStatement) Test(org.junit.Test)

Example 3 with CommandStatement

use of org.teiid.query.sql.proc.CommandStatement in project teiid by teiid.

the class TestSQLStringVisitor method testCreateUpdateProcedure3.

@Test
public void testCreateUpdateProcedure3() {
    Delete d1 = new Delete();
    // $NON-NLS-1$
    d1.setGroup(new GroupSymbol("g"));
    CommandStatement cmdStmt = new CommandStatement(d1);
    // $NON-NLS-1$
    AssignmentStatement assigStmt = new AssignmentStatement(new ElementSymbol("a"), new Constant(new Integer(1)));
    // $NON-NLS-1$
    RaiseStatement errStmt = new RaiseStatement(new Constant("My Error"));
    Block b = new Block();
    b.addStatement(cmdStmt);
    b.addStatement(assigStmt);
    b.addStatement(errStmt);
    CreateProcedureCommand cup = new CreateProcedureCommand(b);
    // $NON-NLS-1$
    helpTest(cup, "BEGIN\nDELETE FROM g;\na = 1;\nRAISE 'My Error';\nEND");
}
Also used : CommandStatement(org.teiid.query.sql.proc.CommandStatement) CreateProcedureCommand(org.teiid.query.sql.proc.CreateProcedureCommand) AssignmentStatement(org.teiid.query.sql.proc.AssignmentStatement) Block(org.teiid.query.sql.proc.Block) RaiseStatement(org.teiid.query.sql.proc.RaiseStatement) Test(org.junit.Test)

Example 4 with CommandStatement

use of org.teiid.query.sql.proc.CommandStatement in project teiid by teiid.

the class TestCommandStatement method testEquivalence.

public void testEquivalence() {
    CommandStatement s1 = sample1();
    CommandStatement s1a = sample1();
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1a);
}
Also used : CommandStatement(org.teiid.query.sql.proc.CommandStatement)

Example 5 with CommandStatement

use of org.teiid.query.sql.proc.CommandStatement in project teiid by teiid.

the class TestCommandStatement method testSelfEquivalence.

// ################################## ACTUAL TESTS ################################
public void testSelfEquivalence() {
    CommandStatement s1 = sample1();
    int equals = 0;
    UnitTestUtil.helpTestEquivalence(equals, s1, s1);
}
Also used : CommandStatement(org.teiid.query.sql.proc.CommandStatement)

Aggregations

CommandStatement (org.teiid.query.sql.proc.CommandStatement)12 Test (org.junit.Test)8 AssignmentStatement (org.teiid.query.sql.proc.AssignmentStatement)4 Block (org.teiid.query.sql.proc.Block)4 CreateProcedureCommand (org.teiid.query.sql.proc.CreateProcedureCommand)4 RaiseStatement (org.teiid.query.sql.proc.RaiseStatement)4 ArrayList (java.util.ArrayList)1 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 Insert (org.teiid.query.sql.lang.Insert)1 Statement (org.teiid.query.sql.proc.Statement)1 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)1 Expression (org.teiid.query.sql.symbol.Expression)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1 SymbolMap (org.teiid.query.sql.util.SymbolMap)1 ExpressionMappingVisitor (org.teiid.query.sql.visitor.ExpressionMappingVisitor)1