Stored Procedures and Open SQL
A stored procedure, like any other SQL statement, can be directly executed on an
RWDBOSql object. However, there are some minor variations. The SQL syntax for the stored procedure invocation depends on how the application wants the stored procedure to be invoked. For RPC invocation, the kind of invocation recommended by Sybase for improved performance, the SQL command is simply the name of the stored procedure.
By default, an
RWDBOSql object treats all SQL statements as queries and sends them to the server as language commands until indicated otherwise. (Please see the
RWDBOSql entry in the
SourcePro API Reference Guide) For RPC invocation of stored procedures, the
statementType parameter of either the
RWDBOSql's constructor or the
statement() method must be passed in as
RWDBOSql::Procedure, as shown in the following statements:
RWDBOSql myOpenSqlObject("myStoredProc", RWDBOSql::Procedure);
or
myOpenSqlObject.statement(“myStoredProc”, RWDBOSql::Procedure);
Here,
myStoredProc is the stored procedure name, and
myOpenSqlObject is an
RWDBOSql instance.
If statementType is not given as RWDBOSql::Procedure, a command is sent as a language command. If a stored procedure is sent as a language command, the SQL syntax for the stored procedure invocation may require placeholders for all parameters. Please see the Sybase documentation for more details.
An Open SQL Stored Procedure Example demonstrates how to use
RWDBOSql with stored procedures.
NOTE: Stored procedure execution is not supported with the data callback classes.