Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

2.8 Stored Procedures

Stored procedures are encapsulated by the class RWDBStoredProc. The implementation of stored procedures by the DBTools.h++ access library for Informix is subject to many restrictions. These restrictions are due to a combination of factors dictated by the Informix SQL grammar and the capabilities of the Informix ODBC Driver:

2.8.1 Creating a Stored Procedure

Use the createProcedure method of RWDBDatabase to create a stored procedure. DBTools.h++ creates the parameter list from a schema you supply. You must supply the text of the stored procedure. Here is a simple example of creating an Informix stored procedure using DBTools.h++:

Note that Informix does not support In/Out parameters, so you do not need to specify a parameter type in the schema you pass to createProcedure().

2.8.2 Executing Stored Procedures

An Informix stored procedure returns zero or more rows of values. If you execute a stored procedure that does not return any values, it is executed immediately when your application calls RWDBStoredProc::execute().

Here is an example of executing a stored procedure that does not return values:

If you execute a stored procedure that does return rows, you must first fetch a row. This can be done by obtaining a reader from the execute method. The first time a row is fetched, the procedure is actually executed in the database.

If you want to execute a stored procedure that returns values, and you are not interested in using the values returned, you can write something like this:

2.8.3 Instantiating an RWDBStoredProcedure Using Schema Data

The member function:

increases 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. For example, the code in Section 2.8.1 uses the schema params to create the stored procedure; params could be used to instantiate an RWDBStoredProc.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.