use of org.teiid.query.sql.lang.AlterProcedure in project teiid by teiid.
the class TestAlterResolving method testAlterProcedure.
@Test
public void testAlterProcedure() {
AlterProcedure alterProc = (AlterProcedure) helpResolve("alter procedure MMSP5 as begin select param1; end", RealMetadataFactory.exampleBQTCached());
assertNotNull(alterProc.getTarget().getMetadataID());
Query q = (Query) ((CommandStatement) alterProc.getDefinition().getBlock().getStatements().get(0)).getCommand();
assertTrue(((ElementSymbol) q.getSelect().getSymbol(0)).isExternalReference());
}
use of org.teiid.query.sql.lang.AlterProcedure in project teiid by teiid.
the class AlterResolver method resolveCommand.
@Override
public void resolveCommand(Command command, TempMetadataAdapter metadata, boolean resolveNullLiterals) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Alter<? extends Command> alter = (Alter<? extends Command>) command;
ResolverUtil.resolveGroup(alter.getTarget(), metadata);
int type = Command.TYPE_QUERY;
boolean viewTarget = true;
if (alter instanceof AlterTrigger) {
TriggerEvent event = ((AlterTrigger) alter).getEvent();
switch(event) {
case DELETE:
type = Command.TYPE_DELETE;
break;
case INSERT:
type = Command.TYPE_INSERT;
break;
case UPDATE:
type = Command.TYPE_UPDATE;
break;
}
if (((AlterTrigger) alter).isAfter()) {
viewTarget = false;
}
} else if (alter instanceof AlterProcedure) {
type = Command.TYPE_STORED_PROCEDURE;
viewTarget = false;
}
if (viewTarget && !QueryResolver.isView(alter.getTarget(), metadata)) {
throw new QueryResolverException(QueryPlugin.Event.TEIID30116, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30116, alter.getTarget()));
}
if (alter.getDefinition() != null) {
QueryResolver.resolveCommand(alter.getDefinition(), alter.getTarget(), type, metadata.getDesignTimeMetadata(), false);
}
}
Aggregations