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 Creating Stored Procedures.
 
RWDBStoredProc avg = aDB.storedProc("averageSalary", conn);
double averageSalary;
avg << &averageSalary;
RWDBTable aboveAverageSalaries = avg.execute(conn).table();
RWDBReader reader = aboveAverageSalaries.reader(conn);
RWDBValue name, title, salary;
while (reader()) {
//save or display the rows
reader >> name >> title >> salary;
cout << name.asString() << "\t" << title.asString()
<< "\t" << salary.asDouble() << endl;
}
avg.fetchReturnParams();
// save or display averageSalary
cout << "averageSalary" << averageSalary << endl;
RWDBValue returnValue = avg.returnValue();
// save or display the return value
cout << "returnValue" << returnValue.asInt() << endl;