CREATE PROCEDURE Statement - IBM DB2 to PostgreSQL Migration

SQLines SQL Converter can help you convert IBM DB2 stored procedures to PostgreSQL:

IBM DB2:

  --#SET TERMINATOR /
 
  CREATE PROCEDURE sp_updateDeptLoc (IN p_loc VARCHAR(25), IN p_deptno CHARACTER(5)) 
  LANGUAGE SQL
  BEGIN 
    UPDATE dept SET location = p_loc WHERE deptno = p_deptno;
  END
  /

The corresponding code in PostgreSQL:

PostgreSQL:

  CREATE OR REPLACE FUNCTION sp_updateDeptLoc (IN p_loc VARCHAR(25), IN p_deptno CHARACTER(5)) 
  RETURNS VOID 
  AS $$
  BEGIN 
    UPDATE dept SET location = p_loc WHERE deptno = p_deptno;
  END;
  $$ LANGUAGE plpgsql;

For more examples, please see IBM DB2 to PostgreSQL Migration Reference