Search in sources :

Example 1 with AssignmentStatement

use of org.teiid.query.sql.proc.AssignmentStatement 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 AssignmentStatement

use of org.teiid.query.sql.proc.AssignmentStatement 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 AssignmentStatement

use of org.teiid.query.sql.proc.AssignmentStatement 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 AssignmentStatement

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

the class TestAssignmentStatement method testGetExpression.

public void testGetExpression() {
    AssignmentStatement s1 = sample1();
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("Didn't get the same parts ", s1.getExpression(), new Constant("1"));
}
Also used : AssignmentStatement(org.teiid.query.sql.proc.AssignmentStatement) Constant(org.teiid.query.sql.symbol.Constant)

Example 5 with AssignmentStatement

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

the class TestAssignmentStatement method testNonEquivalence.

public void testNonEquivalence() {
    AssignmentStatement s1 = sample1();
    AssignmentStatement s2 = sample2();
    int equals = -1;
    UnitTestUtil.helpTestEquivalence(equals, s1, s2);
}
Also used : AssignmentStatement(org.teiid.query.sql.proc.AssignmentStatement)

Aggregations

AssignmentStatement (org.teiid.query.sql.proc.AssignmentStatement)14 Test (org.junit.Test)7 Block (org.teiid.query.sql.proc.Block)5 CommandStatement (org.teiid.query.sql.proc.CommandStatement)4 RaiseStatement (org.teiid.query.sql.proc.RaiseStatement)4 CreateProcedureCommand (org.teiid.query.sql.proc.CreateProcedureCommand)3 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)3 Query (org.teiid.query.sql.lang.Query)2 From (org.teiid.query.sql.lang.From)1 Select (org.teiid.query.sql.lang.Select)1 UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)1 LoopStatement (org.teiid.query.sql.proc.LoopStatement)1 TriggerAction (org.teiid.query.sql.proc.TriggerAction)1 Constant (org.teiid.query.sql.symbol.Constant)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1