Stored Procedures

From Apache OpenOffice Wiki
Jump to: navigation, search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.



Stored procedures are server-side processes execute several SQL commands in a single step, and can be embedded in a server language for stored procedures with enhanced control capabilities. A procedure call usually has to be parameterized, and the results are result sets and additional out parameters. Stored procedures are handled by the method prepareCall() of the interface com.sun.star.sdbc.XConnection.

  com::sun::star::sdbc::XPreparedStatement prepareCall( [in] string sql)

The method prepareCall() takes a an SQL statement that may contain one or more '?' in parameter placeholders. It returns a com.sun.star.sdbc.CallableStatement. A CallableStatement is a com.sun.star.sdbcx.PreparedStatement with two additional interfaces for out parameters:

com.sun.star.sdbc.XOutParameters is used to declare parameters as out parameters. All out parameters must be registered before a stored procedure is executed.

Methods of com.sun.star.sdbc.XOutParameters
registerOutParameter() Takes the arguments long parameterIndex, long sqlType, string typeName. Registers an output parameter and should be used for a user-named or REF output parameter. Examples of user-named types include: STRUCT, DISTINCT, OBJECT, and named array types.
registerNumericOutParameter() Takes the arguments long parameterIndex, long sqlType, long scale. Registers an out parameter in the ordinal position parameterIndex with the com.sun.star.sdbc.DataType sqlType; scale is the number of digits on the right-hand side of the decimal point.

The com.sun.star.sdbc.XRow is used to retrieve the values of out parameters. It consists of getXXX() methods and should be well-known from the common result sets.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages