plsql - Dynamic SQL and Cursor related issue -


i have declared cursor , used in procedure body, have dynamic sql statement creates table on fly. after need access same cursor declared.

when try open cursor before execution of dynamic sql statement working fine.

when try open cursor after execution of dynamic sql statement not opening , cursor.

please me.

thank you.

   create or replace procedure(columns varchar2)       column_names varchar2(100);    sql_query varchar2(200);    begin        select pk_cols column_names        rules rule_column=columns;         sql_query:='create global temporary table ('||column_names||')';        execute immediate sql_query;    end; 

creating table ddl in oracle results in implicit commit, ending transaction.

to solve problem create table inside autonomous transaction:

  -- open cursor    declare     pragma autonomous_transaction;   begin     execute immediate 'create table ...';   end;    -- more cursor 

for more information autonomous transactions, see this overview on tim hall's excellent site.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -