Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Access Module for DB2 CLI User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.9 Stored Procedures

Stored procedures are encapsulated by class RWDBStoredProc. The implementation of stored procedures by the DB Access Module for DB2 CLI provides full support for DB2 stored procedures. This includes support for:

DB2 CLI supports stored procedures written in the SQL language as well as external procedures written in other languages. Please see the DB2 CLI documentation for details regarding stored procedures written in languages other than SQL.

2.9.1 Creating Stored Procedures

Stored procedures can be created by calling the createProcedure() method of RWDBDatabase. The DB Interface Module creates the parameter list from a schema you supply, while the body of the stored procedure is supplied by the application. Here is a simple SQL procedure example, which returns the average employee salary as an output parameter, returns the total of all salaries as a return value, and returns a table of all the employees whose salary is greater than the average:

The createProcedure() method uses the DB2 SQL statement CREATE PROCEDURE. For this reason, it can also register stored procedures with the application server when they are written in languages other than SQL. Please see the DB2 documentation for more information.

2.9.2 Executing Stored Procedures

DB2 stored procedures can be written in several different languages. Once a stored procedure is registered with the server, a client application can execute it. Stored procedures are executed using the CLI CALL statement. An application has the option of processing output parameters, a return value, and/or the result sets returned by the procedure.

Here's an example of processing all the different parts of the stored procedure. We'll use the example procedure shown in Section 2.9.1, "Creating Stored Procedures."

2.9.3 Instantiating an RWDBStoredProc Using Schema Data

The member functions:

increase the performance of stored procedures by eliminating the usual parameter fetch required for instantiation. The schema must include the RWDBColumn::ParamType of each parameter in the stored procedure. The column is ignored as all SQL procedures in DB2 CLI return an integer. For example, the code in Section 2.9.1 uses the schema params to create the stored procedure; params could also be used to instantiate an RWDBStoredProc.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.