How can we write below pseudo code in db2,

If (Proc exists)
  Drop Proc
  Create Proc
Else
 Create Proc

One solution I discovered, after searching would be to disregard the return codes. Do there exists a more elegant method of doing this?

Thanks


Update: With the aid of the solution here we authored a proc as below to decrease the methods

  CREATE PROCEDURE SVCASNDB.DROPSP(IN P_SPECIFICNAME VARCHAR(128))
        SPECIFIC DROPSP

        P1: BEGIN


        -- Drop the SP if it already exists
        if exists (SELECT SPECIFICNAME FROM SYSIBM.SYSROUTINES WHERE SPECIFICNAME = trim(upper(p_SpecificName))) then
        	begin
        		DECLARE v_StmtString VARCHAR (1024);
        		SET v_StmtString = 'DROP SPECIFIC PROCEDURE SCHEMA.' || p_SpecificName;
        		PREPARE stmt1 FROM v_StmtString ;
        		EXECUTE stmt1;
        	end;
        end if;

    END P1

this question: Choose DISTINCT ROUTINENAME, RESULT_SETS, REMARKS FROM SYSIBM.SYSROUTINES where ROUTINESCHEMA='' And Performance_TYPE NOT IN ('S', 'T') (in which you specify your schema title in the placeholder) provides you with all procs inside a schema. Therefore the Proc is available part is just an Is available query on that view using the proper proc title.