views:

1314

answers:

3

I would like to search through all of my procedures packages and functions for a certain phrase.

Since it is possible to retrieve the code for compiled procedures using toad I assume that the full text is stored in some data dictionary table. Does anyone know where that would be?

Thanks a lot

+1  A: 

Do you mean using PL/SQL? Or just using TOAD? I know that you can use the "Find Objects" (or something like that) feature to manually search through all objects like procs, tables, etc...

Mark
I mean the plsql code for my plsql procedures, yes. The toad find objects search isn't working for me, don't know why (also, I would just like to know where the text for procedures is stored)
George Mauer
+7  A: 

You can do something like

SELECT name, line, text
  FROM dba_source
 WHERE text LIKE '%<<your phrase>>%'
Justin Cave
Awesome, thanks!
George Mauer
Justin, can you post your vacation schedule somewhere, so I'll know when I might get some answers in?
can i suggest that you make that a little more robust by allowing escaping of _ and % (quite common in search terms of pl/sql code, i find) and losing the case sensitivity? ... where upper(text) like upper('%<<your\_phrase>>%') escape '\'
David Aldridge
You can use user_source instead of dba_source if you don't have access to dba_source and/or just want to search through the code for a particular schema.
Nick Pierpoint
A: 

Toad's "object search" routine will look through ALL_SOURCE (and other parts of the data dictionary). Of course, this will be limited to the objects the connected user is allowed to see. If you have access to the DBA version, great. If not, you won't be searching everything.

Also, if you're way back on Oracle 7, or your database was migrated up from Oracle 7 to 8i or 9i (not sure about 10 or 11), then trigger source may not appear in the user_source or all_source views. Best to check. The easiest way I've found to get it to appear is to do an actual modification -- add a space, for example -- and recompile the trigger.

Jim Hudson