Search code examples
sqlmoduledb2routines

Replace a routine declared in a DB2 module


I am developing an application in DB2 with SQL PL, and the routines (procedures and functions) are being defined in a module.

However, each time I change a routine, I cannot replace it, and I have to drop the module body, and recreated.

Is there any way to do a REPLACE for a routine inside a module?


Solution

  • In order to replace a routine (stored procedure or function) in a module, it is not necessary to drop the body and recreate all objects.

    In order to replace a routine, it is possible to drop a specific procedure/function, and just recreate it:

    ALTER MODULE m1 ADD PROCEDURE p1 ()
     BEGIN
      ...
     END@
    ALTER MODULE m1 DROP PROCEDURE p1@
    ALTER MODULE m1 ADD PROCEDURE p1 ()
     BEGIN
      ...
     END@
    

    However, there is not a real REPLACE operation.