oracle11g - Oracle 11g temporary list object from query -
i'm trying find if there way in oracle 11g, can store resulting list select variable (object) , loop through list performing second query on results?
basically trying do, list of tables column name, removing data them tables.
something like:
var productid_table = select table_name user_tab_columns column_name = 'product_id' , table_name not 'bin%'; t in productid_table loop delete t.table_name product_id = {value}; end loop; commit;
thanks in advance
ks
you can generate delete statements this:
select 'delete ' || table_name || ' product_id = {value}; ' user_tab_columns column_name = 'product_id' , table_name not 'bin%';
or, if using pl/sql option, can use execute immediate inside pl/sql block:
begin v_rec in (select table_name user_tab_columns column_name = 'product_id' , table_name not 'bin%') loop execute immediate 'delete ' || v_rec.table_name || ' product_id = {value}; '; end loop; end;
Comments
Post a Comment