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 properly. We 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 @
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.