Calling (executing) a stored procedure (function) requires the following steps:
Lets say we want to call a procedure TestProc with two numeric parameters n1 and n2 where n1 is input parameter and n2 is input/output parameter. Procedure will add n1 and n2 and assign the result to n2 (n2 = n1+n2).
SACommand cmd(&Connection, "TestProc");
The line above creates a command object cmd based on previously created and connected connection object Connection (for creating and connection Connection object see Connecting to databases). Second parameter is the name of the required procedure. Required procedure can also be provided using SACommand::setCommandText method.
After parameters are created (automatically by the Library or manually) they all initialized to null values. There are two methods of assigning values to them.
Using ordinary assignment:
cmd.Param("n1").setAsLong() = 5;
cmd.Param("n2").setAsLong() = 10;
Using stream binding operator:
cmd << SAPos("n1") << 5 << SAPos("n2") << 10;
To actually execute a procedure call SACommand::Execute method.
If stored procedure does not generate result set(s) you can reach output parameters immediately after calling SACommand::Execute:
After the statement has been executed, SQLAPI++ stores the returned values of output parameters in the SAParam objects bound to those parameters. On some servers these returned values are not guaranteed to be set until all results returned by the procedure have been fetched (using SACommand::FetchNext method). See Server specific information on output parameters availability on different DBMSs.
That is all there is to it. Steps 2-4 can be repeated if you need to call procedure several times.
If you haven't found the answer to your questions or have some problems using the Library, please, send e-mail to email@example.com.