Can an oracle SQL query execute a string query selected from a table?

前端 未结 3 1547
迷失自我
迷失自我 2021-01-23 10:34

When using oracle SQL is it possible to run a query based on a text_string from a subquery? An example might clarify what I\'m trying to do

    select count(sql_         


        
3条回答
  •  情深已故
    2021-01-23 10:45

    You can do it in PL/SQL, it can look like this (if I understand your requirement properly):

    create table sql_commands (cmd varchar2(1000));
    insert into sql_commands values ('select * from table_1');
    insert into sql_commands values ('select * from table_2');
    commit;
    
    declare
    begin
       for aLine in (select cmd from sql_commands) loop
          execute immediate aLine.cmd into ... -- depends on your command
       end loop;
    end;
    

提交回复
热议问题