Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for existence of a Stored Proc.

Status
Not open for further replies.
Nov 15, 2000
322
US
I'm creating a routine where I need to drop a Stored Procedure. I only want the command to execute if the SP exists.

How can I get this information to know if the SP exists or not?

Thanks in advance.

Monkeylizard
Sometimes just a few hours of trial and error debugging can save minutes of reading manuals.
 
There is a system table called syscat.routines which has an entry for each of the stored procedures you define on the system.

The other way is to drop the stored procedure and ignore the returned message.

HTH

Sathyaram

For db2 resoruces visit More DB2 questions answered at &
 
I think it's worth mentioning here that if you have more than one stored proc with the same name within the same schema, but with different profiles, you will need to reference syscat.routineparms. This will give you the basis for working out the profile for each procedure.

If you join syscat.routines and syscat.routineparms use an outer join since syscat.routineparms has no rows for routines with no parms, so an inner join would not show stored procs which take no paramaters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top