Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Access Module for ODBC User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

2.17 Open SQL and ODBC

The alternative Open SQL interface can be used with ODBC. This section provides some specific details and examples.

2.17.1 Placeholder Syntax

The placeholder syntax for ODBC is:

?

Here is an example:

INSERT INTO PICNICTABLE VALUES( ? )

The use of placeholders in OpenSQL statements is not a portable feature. The different access modules use different placeholder syntax depending on their underlying vendor implementation.

2.17.2 Supported Data Types for Input Binding

Please see Section 2.15, "Input Binding of Data," for information on the supported data types.

2.17.3 RWDBDataCallback and Open SQL

The data callback classes can be used with ODBC to insert and fetch data. These classes are useful for very large data that may not fit in memory for a single database call and are described in Section 15.3, "The Data Callback Classes," in the DB Interface Module User's Guide.

ODBC drivers vary in their capabilities. Some drivers do not support data callbacks used for columns in the select list before the last bound column. There may also be a restriction on the number of rows that can be fetched at one time from a result set, so that calls to RWDBOSql::fetch() may return only one row. Check the documentation for the SQL_GETDATA_EXTENSIONS supported by the ODBC driver for more information.

Multiple rows can be inserted in one call to RWDBOSql::execute(). The number of rows is determined by the entries parameter passed to the constructor of a data callback class or an RWDBTBuffer instance. Please see Chapter 15, "Using the Open SQL Classes," in the DB Interface Module User's Guide for information about array input.

2.17.3.1 Piece Size Setting

The DB Access Module for ODBC sets the piece size for inserting or fetching data to 32768. This value represents bytes in the case of binary data, and code units in the case of character data.

2.17.3.2 RWDBDataCallback::getLength()

When inserting data using data callbacks, some databases need to be provided the total length of the inserted value, which requires overriding the RWDBDataCallback::getLength() method.

For ODBC, some drivers require the total length of the data value prior to inserting the value when using data callbacks. Either check the ODBC driver documentation for the SQL_NEED_LONG_DATA_LEN option, or call the function SQLGetInfo() with the SQL_NEED_LONG_DATA_LEN option; if it returns "Y", the method must be overridden in the derived classes.

2.17.3.3 Stored Procedures and RWDBDataCallback

Stored procedure execution is not supported with the data callback classes.

2.17.4 Stored Procedures and Open SQL

Apart from the data callback classes, you can use the standard ODBC CALL syntax when executing stored procedures with RWDBOSql. Please see an ODBC API reference for additional information regarding the syntax for this method.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.