How do we write below pseudo code in db2,
If (Proc exists)
Drop Proc
Create Proc
Else
Create Proc
One solution I found, after googling is
this query:
SELECT DISTINCT ROUTINENAME, RESULT_SETS, REMARKS
FROM SYSIBM.SYSROUTINES
WHERE ROUTINESCHEMA='<schema>' AND FUNCTION_TYPE NOT IN ('S', 'T')
(where you specify your schema name at the placeholder) gives you all procs in a schema. So the Proc exists part is simply an EXISTS query on that view with the proper proc name.