ODBC applications can use the parameter names defined in the CA IDMS CREATE PROCEDURE statement when binding parameter values. This technique simplifies parameter binding for procedures with large numbers of parameters, particularly if default values can be used.
The named parameter feature for ODBC is used differently than it is usedfor JDBC because of ODBC use of structures known as descriptors. An application must first bind a data buffer to a parameter marker ('?') in the SQL string using an ordinal index. This process creates an implementation parameter descriptor (IPD). The parameter name can then be set in the IPD to provide the correlation between the IPD and the parameter in the CA IDMS procedure. Because of this correlation, named parameters do not have to be bound in any particular order, and a parameter can be skipped completely if an acceptable default value has been defined in the procedure.
An application uses the following functions for named parameters:
Prepares the SQL CALL statement with one or more parameter markers.
Binds a data buffer and data type information associated with a parameter marker.
Obtains the handle for the IPD associated with a bound parameter.
Sets the SQL_DESC_NAME field in an IPD with the appropriate parameter name from the CREATE PROCEDURE statement.
Calls the procedure and returns output values.
Note that attempting mix unnamed ordinal parameters with named parameters causes an error. If automatic IPD population is used by the application, the IPDs is already in the order of the parameters specified in the CREATE PROCEDURE statement, and named parameters are ignored. Automatic IPD population is enabled by calling SQLSetConnectAttr to set SQL_ATTR_ENABLE_AUTO_IPD to SQL_TRUE. This feature is commonly used by ad-hoc query tools for determining parameter metadata.
For more information, see the Microsoft's ODBC Programmer's Guide.
|
Copyright © 2009 CA.
All rights reserved.
|
|