Tag Archives: stored procedure

How to change the library list before calling an external RPG program in a DB2 SQL stored procedure on IBMi

Below is how you can create a SQL stored procedure that calls the CL command ADDLIBLE to change the library list before calling an external RPG program that may require that Library in the Library List to run properlyWe also handle the error scenario where you might add a library that already exists (which would crash your SQL stored proc).  Let me know if this is helpful by commenting below or tweeting a reply to @php_dave

Advertisements

PHP can handle multiple result sets from a DB2 SQL Stored Procedures on IBM i

Did you know that a DB2 SQL stored procedure can pull back multiple result sets?  Its as simple as adding this to your Create Procedure statement:  DYNAMIC RESULT SETS 2.  You can use any integer value but I used 2.

To access the additional result sets in PHP you can use either odbc_next_result or db2_next_result.  The main advantage of pulling back multiple result sets is that you only have to issue 1 call to a stored procedure to pull back all the information that you may need.

http://php.net/manual/en/function.odbc-next-result.php

http://php.net/manual/en/function.db2-next-result.php