Sunday, August 7, 2011

Find data in a table list

declare

v_sql varchar2(500);

v_cnt number;

begin

for i in (select distinct table_name from
dba_tab_cols where owner='UBSGOLD' and column_name like 'PRODUCT_CODE')
loop


v_cnt := 0;
v_sql := 'select count(*) into :cnt from ' || i.table_name ||
' where product_code in (''ACSW'', ''ATMS'')' ;

execute immediate v_sql into v_cnt;

if v_cnt > 0 then

dbms_output.put_line(i.table_name);
end if;

end loop;
end;

No comments:

Post a Comment