Appendix C: Oracle Call Interface (OCI) Mapping

 < Day Day Up > 



This appendix provides a mapping of the most frequently used Oracle8 OCI calls to the closest DB2 Call Level Interface (CLI) equivalents. Refer to the DB2 Call Level Interface Guide and Reference, Volume 1, SC09-4849, Volume 2, SC09-4850 for details on the CLI calls. Numbers in parentheses refer to the corresponding notes below the tables. N/A means that the OCI call has no equivalent in CLI.

Table 9-8: Connect/initialize/authorize

OCI command

CLI command

OCIInitialize

N/A

OCIEnvInit

SQLAllocHandle ([1])

OCIServerAttach

SQLConnect ([2]), ([3])

OCIServerDetach

SQLDisconnect

OCISessionBegin

N/A ([3])

OCISessionEnd

N/A

OCILogon

SQLConnect ([2])

OCILogoff

SQLDisconnect

[1]SQLAllocHandle is passed the desired handle type: environment, connection, statement, or descriptor.

[2]SQLDriverConnect is an alternative to SQLConnect, providing additional parameters.

[3]OCISessionBegin has no CLI equivalent. To establish multiple database connections in CLI, multiple connection handles must be allocated and OCIServerAttach calls replaced by SQLConnect calls.

Table 9-9: Handles/descriptors

OCI command

CLI command

OCIHandleAlloc

SQLAllocHandle ([1])

OCIHandleFree

SQLFreeHandle

OCIAttrGet

SQLGet__Attr ([4])

OCIParamGet

N/A ([5])

OCIParamSet

N/A ([6])

OCIAttrSet

SQLSet__Attr ([7])

OCIDescriptorAlloc

SQLSetStmtAttr ([5])

OCIDescriptorFree

SQLFreeHandle ([8])

[1]SQLAllocHandle is passed the desired handle type: environment, connection, statement, or descriptor.

[4]OCIAttrGet can be replaced by SQLGetConnectAttr, SQLGetEnvAttr, or SQLGetStmtAttr, depending on the type of handle that the attribute value is wanted for.

[5]5. SQLSetStmtAttr must be called with an Attribute value of SQL_ATTR_APP_PARAM_DESC or SQL_ATTR_APP_ROW_DESC. However, descriptors can be allocated implicitly instead. The function of OCIParamGet is performed by SQLSetStmtAttr (or implicitly).

[6]CLI does not have complex object retrieval (COR) descriptors or handles.

[7]OCIAttrSet can be replaced by SQLSetConnectAttr, SQLSetEnvAttr, or SQLSetStmtAttr, depending on the type of handle for which an attribute value is to be set.

[8]SQLFreeHandle must be called with a HandleType of SQL_HANDLE_DESC (or the connection can be freed).

Table 9-10: Transaction management

OCI command

CLI command

OCITransCommit

SQLEndTran ([9])

OCITransDetach

N/A

OCITransRollback

SQLEndTran ([9])

OCITransStart

N/A

OCITransPrepare

N/A ([10])

OCITransForget

N/A ([10])

[9]SQLEndTran does either a commit or a rollback, depending on the completion type parameter value.

[10]There are no CLI calls specifically for two-phase commit, but it is supported (see CLI Guide and Reference, volume 1, SC09-4849, and volume 2, SC09-4850).

Table 9-11: Bind/define/describe

OCI command

CLI command

OCIBindDynamic

SQL__Data ([11])

OCIBindByName

SQLBindParameter

OCIBindByPos

SQLBindParameter

OCIBindObject

N/A ([12])

OCIBindArrayOfStruct

SQLBindParameter ([13])

OCIStmtGetBindInfo

N/A ([14])

OCIDefineArrayOfStruct

N/A ([13])

OCIDefineDynamic

N/A

OCIDefineByPos

SQLBindCol ([15])

OCIDefineObject

N/A ([12])

OCIDescribeAny

(many) ([16])

[11]For piecewise operations there is no direct replacement for OCIBindDynamic, but for inserts, SQLParamData and SQLPutData must be called, and for selects, SQLGetData.

[12]CLI has no special support for user-defined types. CLI treats one as it does the underlying built-in type. In SQL statements the CAST function must be used to convert a parameter with a user-defined type to the corresponding built-in type (or vice-versa). For more information, see the topic "User Defined Types in Predicates" in the CLI Guide and Reference.

[13]To use array inserts, SQLBindParameter must be called. In addition, calls to SQLSetStmtAttr are needed to set attributes SQL_ATTR_PARAMSET_SIZE (array size) and SQL_ATTR_PARAM_BIND_TYPE (row-wise or column-wise binding of parameters). OCIDefineArrayOfStruct calls can be ignored.

[14]No direct equivalent, but SQLDescribeParam is the closest.

[15]To use array fetches, SQLBindCol must be called. In addition, calls to SQLSetStmtAttr are needed to set attributes SQL_ATTR_ROW_ARRAY_SIZE (array size) and SQL_ATTR_ROW_BIND_TYPE (row-wise or column-wise array retrieval).

[16]An OCIDescribeAny call should be replaced by the appropriate call from among SQLColAttribute, SQLColumns, SQLDescribeCol, SQLForeignKeys, SQLGetFunctions, SQLPrimaryKeys, SQLProcedures, SQLProcedureColumns, SQLSpecialColumns, SQLStatistics, SQLTablePrivileges, and SQLTables.

Table 9-12: Prepare/execute/fetch

OCI command

CLI command

OCIStmtPrepare

SQLPrepare

OCIStmtExecute

SQLExecute

OCIStmtFetch

SQLFetch ([17])

[17]SQLFetch fetches a single row. Use SQLFetchScroll to return a rowset; the simplest type of usage is a basic array fetch.

Table 9-13: Miscellaneous

OCI command

CLI command

OCIBreak

SQLCancel

OCIServerVersion

SQLGetInfo ([18])

OCIPasswordChange

N/A

OCIErrorGet

SQLGetDiagRec

OCIStmtGetPieceInfo

SQLGetData ([11])

OCIStmtSetPieceInfo

SQL__Data ([11])

OCILdaToSvcCtx

N/A

OCISvcCtxToLda

N/A

[18]SQLGetInfo provides much more than the server version. One call is needed per type of information wanted.

[11]For piecewise operations there is no direct replacement for OCIBindDynamic, but for inserts, SQLParamData and SQLPutData must be called, and for selects, SQLGetData.



 < Day Day Up > 



Oracle to DB2 UDB Conversion Guide2003
Oracle to DB2 UDB Conversion Guide2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net