ODBC Stored Procedures Although embedded SQL stored procedures provide the most advantages, application developers who have existing DB2 ODBC applications might wish to move components of the application to run on the server. In order to minimize the required changes to the code and logic of the application, these components can be implemented by writing stored procedures using DB2 ODBC. Autocommit must be turned off and a null connection should be used. The MVSATTACHTYPE keyword should be set to RRSAF if the stored procedure contains any LOB data types or distinct types in its parameter list. DB2 for OS/390 and z/OS requires that stored procedures containing any LOBs or distinct types must run in a WLM-established stored procedure address space. Programming Stored Procedures to Return Result SetsIn a stored procedure, DB2 ODBC uses cursors declared WITH RETURN. Cursors that are closed before the stored procedure exit are local cursors. Cursors that remain open return result sets. In order for a DB2 ODBC stored procedure to return a result set, it must not close the cursor and it must not free the statement handle, the connection handle, or the environment handle. |
Team-Fly |
Top |