Executing Stored Procedures

Stored procedures are executed using the MySQL CALL syntax.

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

 

RWDBStoredProc royalty = aDb.storedProc("royalty");

float percentage;

royalty << myTitleId; // from application input

royalty << myNewSales; // from application input

royalty << &percentage; // will process on return

 

RWDBTable royaltyTable = royalty.execute().table();

RWDBReader reader = royaltyTable.reader();

while (reader())

{

// save or display the royalties

}

// retrieve the output parameters

royalty.fetchReturnParams();

cout << percentage << endl;