Search code examples
sqlsap-iq

How should i execute and get the result of a query which is stored in a column as a data value


How do I execute a Sybase query which is stored in a column of another Sybase table?

Suppose that "SELECT COLa FROM TABLE_A" is stored in a column called 'command' in a separate table (table_log). I want to find a way that allows me to execute this query and get the answer.


Solution

  • Try looking for

    execute immediate
    

    I'm not familiar with sybase but in Oracle it would be something like the following:

    declare
        query varchar2(1000);
    begin
        select val from saved_query into query;
        execute immediate query;
        commit;
    end;