In db2 how to find all the Stored Procedures having a given text in it

谁说我不能喝 提交于 2019-12-02 22:31:55

问题


I want to find if a table is being used anywhere in all the stored procedures in a system. Is there a query to fetch all the details of SP.


回答1:


You can use SYSCAT.TABDEP and SYSCAT.ROUTINEDEP system catalog views.

For tables in Dynamic SQL statements, that are built and executed on the fly, you can use

select routinename,text from syscat.routines where language='SQL' and locate('<table-name>',text)>0

HTH

Sathyaram




回答2:


The accepted answer didn't work for me for our particular flavor of DB2, but it set me in the right direction. Here is the query I wrote which allowed me to search sprocs in a given schema:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM sysibm.routines 
WHERE SPECIFIC_SCHEMA='<YourSchemaName>' 
    AND ROUTINE_DEFINITION LIKE '<YourSearchText>%'

Replace YourSchemaName and YourSearchText with appropriate values.



来源:https://stackoverflow.com/questions/15087281/in-db2-how-to-find-all-the-stored-procedures-having-a-given-text-in-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!