I have searched the net and I've found a post that uses the following snippet to check if a stored procedure exists:
select *
from USER_SOURCE
where type='PROCEDURE'
and name='my_stored_procedure.'
Is there any other way to check if a procedure exists?
Edited to add:
Before posting SQL Server ways, please I'm looking for ORACLE ways.
In the Object Explorer in SQL Server Management Studio, go to the database and expand it. Expand the Programmability folder. Right Click the Stored Procedures folder. From the right-click menu, select Filter in the right-click menu.
Alternatives:
USER_PROCEDURES:
SELECT *
FROM USER_PROCEDURES
WHERE object_name = 'MY_STORED_PROCEDURE'
USER_OBJECTS:
SELECT *
FROM USER_OBJECTS
WHERE object_type = 'PROCEDURE'
AND object_name = 'MY_STORED_PROCEDURE'
The only way to see if a procedure exists in the database is though querying DBA_OBJECTS
. The disadvantage here is that only a dba has access to this view. Second best is using all_objects. ALL_OBJECTS
shows you the objects for which you have somehow a privilege. USER_OBJECTS
only shows you your own objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With