Created
August 27, 2018 14:36
-
-
Save arfeo/0e4f79956cf164ed41926b09c9d0b622 to your computer and use it in GitHub Desktop.
Oracle: full text search in all tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace procedure whereIsValue(valueParam varchar2) | |
AS | |
TYPE VALCUR IS REF CURSOR; | |
cursor tabl is select table_name from user_tables; | |
cursor col (tablename varchar2) is select column_name | |
from user_tab_columns | |
where table_name like tableName; | |
valueCursor VALCUR; | |
tableName varchar2(50); | |
columnName varchar2(50); | |
columnValue varchar2(500); | |
qq number(3); | |
begin | |
open tabl; | |
LOOP | |
fetch tabl into tableName; | |
EXIT WHEN tabl%NOTFOUND; | |
OPEN col(tableName); | |
LOOP | |
fetch col into columnName; | |
EXIT WHEN col%NOTFOUND; | |
OPEN valueCursor for 'select ' || columnName | |
|| ' from ' || tableName; | |
LOOP | |
BEGIN | |
fetch valueCursor into columnValue; | |
EXIT WHEN valueCursor%NOTFOUND; | |
if (columnValue like valueParam) then | |
dbms_output.put_line(tableName); | |
exit; | |
end if; | |
EXCEPTION | |
WHEN OTHERS then | |
qq := 4; | |
END; | |
END LOOP; | |
CLOSE valueCursor; | |
END LOOP; | |
CLOSE col; | |
END LOOP; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment