use of org.teiid.query.sql.proc.CreateProcedureCommand 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");
}
use of org.teiid.query.sql.proc.CreateProcedureCommand 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");
}
use of org.teiid.query.sql.proc.CreateProcedureCommand in project teiid by teiid.
the class TestResolver method helpResolveUpdateProcedure.
CreateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr) throws QueryParserException, QueryResolverException, TeiidComponentException, QueryMetadataException {
QueryMetadataInterface metadata = RealMetadataFactory.exampleUpdateProc(TriggerEvent.UPDATE, procedure);
ProcedureContainer userCommand = (ProcedureContainer) QueryParser.getQueryParser().parseCommand(userUpdateStr);
QueryResolver.resolveCommand(userCommand, metadata);
return (CreateProcedureCommand) QueryResolver.expandCommand(userCommand, metadata, AnalysisRecord.createNonRecordingRecord());
}
use of org.teiid.query.sql.proc.CreateProcedureCommand in project teiid by teiid.
the class TestProcedureResolving method testDefect23257.
/**
* Constants will now auto resolve if they are consistently representable in the target type
*/
@Test
public void testDefect23257() throws Exception {
// $NON-NLS-1$
CreateProcedureCommand command = (CreateProcedureCommand) helpResolve("EXEC pm6.vsp59()", RealMetadataFactory.example1Cached());
CommandStatement cs = (CommandStatement) command.getBlock().getStatements().get(1);
Insert insert = (Insert) cs.getCommand();
assertEquals(DataTypeManager.DefaultDataClasses.SHORT, ((Expression) insert.getValues().get(1)).getType());
}
use of org.teiid.query.sql.proc.CreateProcedureCommand in project teiid by teiid.
the class TestProcedureResolving method testAnonBlock.
@Test
public void testAnonBlock() throws Exception {
// $NON-NLS-1$
String sql = "begin select 1 as something; end";
CreateProcedureCommand sp = (CreateProcedureCommand) TestResolver.helpResolve(sql, RealMetadataFactory.example1Cached());
assertEquals(1, sp.getResultSetColumns().size());
assertEquals("something", Symbol.getName(sp.getResultSetColumns().get(0)));
assertEquals(1, sp.getProjectedSymbols().size());
assertTrue(sp.returnsResultSet());
}
Aggregations