Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find a string within the source code (DDL) of a stored procedure in oracle

Tags:

string

sql

oracle

I need to find a string in the source code (DDL) for all stored procedures in Oracle schema.

I use this query to perform the task, but I think can be improved

SELECT T0.OBJECT_NAME
FROM USER_PROCEDURES T0 
WHERE T0.OBJECT_TYPE='PROCEDURE'
AND INSTR( (SELECT DBMS_METADATA.GET_DDL('PROCEDURE',T0.OBJECT_NAME,'MySCHEMA') 
            FROM DUAL), 'TheStringToSearch' )>0

is there a way of accomplishing this task in a more optimal and fast way?

thanks in advance.

like image 675
RRUZ Avatar asked Dec 09 '22 18:12

RRUZ


1 Answers

Yes, use USER_SOURCE:

select distinct name
from   user_source
where  type = 'PROCEDURE'
and    lower(text) like lower('%the_text_you_want%');
like image 127
Tony Andrews Avatar answered May 09 '23 21:05

Tony Andrews