Function to find specific value in any table any column

Steps to use the following function: Replace the string highlighted in bold/red, with the string you want to search.

Note: the following function is tested & working fine in Oracle DB.

declare
cursor c1 is select column_name , table_name from user_tab_columns where
data_type = 'VARCHAR2';-- and table_name = 'REV_DIM_ATTRIBUTES_B' ;

vSQL varchar2(32676) := null;
vParam varchar2(100) := '10.184.75.23';
vcnt number;
begin
for x in c1 loop
begin
vSQL := 'select count(*) from '||x.table_name||' where '||x.column_name||' like '||chr(39)||'%'||vparam||'%'||chr(39);
execute immediate vSQL into vcnt;

if vcnt > 0 then
dbms_output.put_line('Found in '||x.table_name||' '||x.column_name);
end if;
exception when others then
dbms_output.put_line('Problem in '||vSQL);
end;
end loop;
end;

Comments

Popular posts from this blog

Steps to Deploy the OFSAA application in WEBLOGIC server:

Client / Server Applications

Steps for OFSAA ALM cash flow generation