| Home | How To | Online Documentation | Support | Download | Order |
|
|
Server Specific GuideOracleSQLAPI++ allows to work with a number of SQL database servers. It provides common mechanisms to access database, and as a general rule they work for any database server. But each server has some specific features which a developer has to know in order to leverage server's unique features and avoid potential errors. This page collects all specific information that concerns working with Oracle server using SQLAPI++ Library. Full information about using SQLAPI++ see in How To and Online Documentation. Available topics: Working with Long or Lob(CLob, BLob) data Connection, command, parameter and field options Getting native Oracle connection related handles Getting native Oracle command related handles Special header files - Compile time
Connecting to a databaseTo connect to a database you should create a connection object and then connect it. A connection object is represented by SAConnection class. After the connection is created you need to connect it to Oracle server using SAConnection::Connect method void Connect( const SAString &sDBString,
const
SAString &sUserID, const SAString &sPassword,
SAClient_t eSAClient = SA_Client_NotSpecified ); with the following parameters: sDBString. The database name as it
is specified in TNSNAMES.ORA file. An additional information about
Oracle connection string available with Oracle
Instant
Client FAQ
(<hostname>[:<port>][/<service_name>] ).
The SQLAPI++ Library requires OCI version 7.3 or higher. The Library tries to connect to Oracle using new OCI8 (Oracle 8 and higher) first. If it fails it tries to connect using OCI7. If you want to use directly OCI7 or OCI8 API you should set "UseAPI" connection option before specifying Oracle client or connecting to database. For more details see How To - Connecting to databases, SAConnection object, SAConnection::Connect, SAConnection::setOption
Transaction isolation levelsSQL-92 defines four isolation levels, all of which are supported by SQLAPI++:
SQLAPI++ maps different isolation levels on Oracle server in the following way: SA_ReadUncommitted
= 'READ COMMITTED' For more details see SAConnection::setIsolationLevel.
Working with Long or Lob(CLob, BLob) data1. SQLAPI++ supports four types for working with Lob(CLob, BLob) data:
The table below shows how SQLAPI++ data types correspond with servers original data types:
For more details see How To - Working with Long or Lob(CLob, BLob) data 2. Binding Lob(CLob, BLob) data when working with Oracle server has some differences from others (see How To - Binding input parameters). It's necessary for a name of bind variable to be the same as the column name it associated with. Ex.: Update TEST set FBLOB = :fblob where FKEY = 'KEY' Therefore, it's impossible to bind Lob(CLob, BLob) data to Oracle database by position. For more details see How To - Binding input parameters.
Returning output parametersIn Oracle output parameters are available immediately after calling SACommand::Execute. SQLAPI++ Library automatically creates SAParam object to represent function return value. You can refer to this SAParam object using SQLAPI++ predefined name "RETURN_VALUE". For more details see SACommand::Execute, SAParam object, How To - Returning Output Parameters.
Cancelling queriesUsing SACommand::Cancel method you can cancel the following types of processing on a statement:
SQLAPI++ calls obreak function with Oracle 7 (OCI7) to cancel a query. To get more details see obreak function description in Oracle documentation. SQLAPI++ calls OCIBreak function with Oracle 8 (OCI8) to cancel a query. To get more details see OCIBreak function description in Oracle documentation. For more details see SACommand::Cancel.
Connection, command, parameter and field optionsA server specific option can relate to a connection, command, parameter or field. We recommend you specify each option in an appropriate object, although it is possible to specify them in the parental object as well. In that case the option affects all the child objects. A connection related option must be specified in a SAConnection object. A command related option may be specified in either SAConnection object or SACommand object. If it is specified in SAConnection object it affects all the commands on that connection. A parameter related option may be specified in SAConnection object, SACommand object or SAParam object. If it is specified in SAConnection object it affects all the commands and therefore all the parameters on that connection. If it is specified in SACommand object it affects all the parameters on that command. A field related option may be specified in SAConnection object, SACommand object or SAField object. If it is specified in SAConnection object it affects all the commands and therefore all the fields on that connection. If it is specified in SACommand object it affects all the fields on that command. Specific options for Oracle:
For more details see SAConnection::setOption, SACommand::setOption, SAField::setOption, SAParam::setOption.
Getting native Oracle APIYou can call client specific API functions which are not directly supported by SQLAPI++ Library. SAConnection::NativeAPI method returns a pointer to the set of native API functions available for Oracle . To use the database API directly you have to downcast this saAPI pointer to the appropriate type and use its implementation-specific members. The following table shows what type cast you have to make and what additional header file you have to include to work with Oracle API. Note that using appropriate type casting depends on an API version (that generally mean that you have to explicitly check client version before casting, see SAConnection::ClientVersion method).
To get more information about DBMS API functions see this DBMS specific documentation. For more details see SAConnection::NativeAPI.
Getting native Oracle connection related handlesYou have to use native API handles when you want to call specific Oracle API functions which are not directly supported by the Library. API functions usually need to receive one or more active handles as a parameter(s). SAConnection::NativeHandles method returns a pointer to the set of native API connection related handles. To use API handles directly you have to downcast saConnectionHandles pointer to the appropriate type and use its implementation-specific members. The following table shows what type cast you have to make and what additional header file you have to include to work with specific Oracle API. Note that using appropriate type casting depends on an API version (that generally mean that you have to explicitly check client version before casting, see SAConnection::ClientVersion method).
To get more information about DBMS API functions and handles see this DBMS specific documentation. For more details see SAConnection::NativeHandles.
Getting native Oracle command related handlesYou have to use native API handles when you want to call specific Oracle API functions which are not directly supported by the Library. API functions usually need to receive one or more active handles as a parameter(s). SACommand::NativeHandles method returns a pointer to the set of native API command related handles. To use API handles directly you have to downcast saCommandHandles pointer to the appropriate type and use its implementation-specific members. The following table shows what type cast you have to make and what additional header file you have to include to work with specific Oracle API. Note that using appropriate type casting depends on an API version (that generally mean that you have to explicitly check client version before casting, see SAConnection::ClientVersion method).
To get more information about DBMS API functions and handles see this DBMS specific documentation. For more details see SACommand::NativeHandles.
Error handlingWhen an error occurs inside SQLAPI++ Library it throws an exception of type SAException. SAException::ErrPos method gets an error position in SQL statement. In Oracle server SAException::ErrPos method returns parse error offset. For more details see How To - Error handling, SAException object.
Special header files - Compile timeThe header files are in the include
subdirectory of SQLAPI++ distributions: For more details see Online Documentation - Instructions for Compiling and Linking Applications with SQLAPI++
Problems and QuestionsIf you haven't found the answer to you questions or have some problems on using the Library, please, send e-mail to howto@sqlapi.com. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||