Search in sources :

Example 1 with AlterProcedure

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());
}
Also used : AlterProcedure(org.teiid.query.sql.lang.AlterProcedure) Query(org.teiid.query.sql.lang.Query) Test(org.junit.Test)

Example 2 with AlterProcedure

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);
    }
}
Also used : Alter(org.teiid.query.sql.lang.Alter) AlterProcedure(org.teiid.query.sql.lang.AlterProcedure) Command(org.teiid.query.sql.lang.Command) TriggerEvent(org.teiid.metadata.Table.TriggerEvent) AlterTrigger(org.teiid.query.sql.lang.AlterTrigger) QueryResolverException(org.teiid.api.exception.query.QueryResolverException)

Aggregations

AlterProcedure (org.teiid.query.sql.lang.AlterProcedure)2 Test (org.junit.Test)1 QueryResolverException (org.teiid.api.exception.query.QueryResolverException)1 TriggerEvent (org.teiid.metadata.Table.TriggerEvent)1 Alter (org.teiid.query.sql.lang.Alter)1 AlterTrigger (org.teiid.query.sql.lang.AlterTrigger)1 Command (org.teiid.query.sql.lang.Command)1 Query (org.teiid.query.sql.lang.Query)1