use of org.teiid.query.sql.proc.CreateProcedureCommand in project teiid by teiid.
the class TestProcedureResolving method testReturnAndResultSet.
@Test
public void testReturnAndResultSet() throws Exception {
// $NON-NLS-1$
String ddl = "CREATE FOREIGN PROCEDURE proc (OUT param STRING RESULT) RETURNS TABLE (a INTEGER, b STRING);";
TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "y");
StoredProcedure sp = (StoredProcedure) TestResolver.helpResolve("exec proc()", tm);
assertEquals(2, sp.getProjectedSymbols().size());
assertEquals("y.proc.b", sp.getProjectedSymbols().get(1).toString());
assertTrue(sp.returnsResultSet());
sp.setCallableStatement(true);
assertEquals(3, sp.getProjectedSymbols().size());
assertEquals("y.proc.param", sp.getProjectedSymbols().get(2).toString());
CreateProcedureCommand cpc = (CreateProcedureCommand) TestResolver.helpResolve("begin exec proc(); end", tm);
assertEquals(2, cpc.getProjectedSymbols().size());
assertEquals(2, ((CommandStatement) cpc.getBlock().getStatements().get(0)).getCommand().getProjectedSymbols().size());
assertTrue(cpc.returnsResultSet());
TestValidator.helpValidate("begin declare string var; var = exec proc(); select var; end", new String[] { "SELECT var;" }, tm);
}
use of org.teiid.query.sql.proc.CreateProcedureCommand in project teiid by teiid.
the class TestSQLStringVisitor method testCreateUpdateProcedure2.
@Test
public void testCreateUpdateProcedure2() {
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");
}
Aggregations