I'm trying to restore all the inserts that I've done in my tables. I have a cursor that loops through table names, a second one that loops through all the rows from that table and a third one that loops through all the columns. The problem is that I can't declare a dynamic row because it gives an exception at runtime. Is there any solution to my problem? Or can you suggest another approach?
Here is the code:
declare cursor c_table is select table_name from user_tables; sql_query varchar2(100); rc sys_refcursor; begin for v in c_table loop dbms_output.put_line('INSERT INTO ' || v.table_name ||' VALUES ('); sql_query := 'select * from '||v.table_name; open rc for sql_query; loop ---- here i want to fethc all the rows declare sql_statement varchar2(200); v_column varchar2(50); re sys_refcursor; begin sql_statement := 'select column_name from user_tab_columns where table_name = '|| q'[']' || v.table_name || q'[']'; open re for sql_statement; loop fetch rc into v_column; exit when rc%notfound; end loop; close re; end; end loop; end loop; end;