Home How To Online Documentation Support Download Order
 

 

 


SACommand
SAConnection
SAException
SAField
SAParam
SAString
SADateTime
SANumeric

Enums and Typedefs


Server Specific Guide

Informix

SQLAPI++ 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 Informix server using SQLAPI++ Library. Full information about using SQLAPI++ see in How To and Online Documentation .

Available topics:

Connecting to a database

Transaction isolation levels

Working with Long or Lob(CLob, BLob) data

Returning output parameters

Cancelling queries

Connection, command, parameter and field options

Getting native Informix API

Getting native Informix connection related handles

Getting native Informix command related handles

Error handling

Special header files - Compile time

 

Connecting to a database

To 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 Informix 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.    Any valid Informix connection string.
sUserID.    A string containing a user name to use when establishing the connection.
sPassword.    A string containing a password to use when establishing the connection.
eSAClient.    Optional. One of the following values from SAClient_t enum:

  • SA_Informix_Client    Informix client.
  • SA_Client_NotSpecified     Used by default if eSAClientparameter is omitted.  You can use this default value only if you have call SAConnection::setClient method with SA_Informix_Client constant before.

The SQLAPI++ Library requires Informix CLI version 2.x or higher.

For more details see How To - Connecting to databases, SAConnection object, SAConnection::Connect.

 

Transaction isolation levels

SQL-92 defines four isolation levels, all of which are supported by SQLAPI++:

  • Read uncommitted (the lowest level where transactions are isolated just enough to ensure that physically corrupt data is not read)
  • Read committed
  • Repeatable read
  • Serializable (the highest level, where transactions are completely isolated from one another)

SQLAPI++ maps different isolation levels on Informix server in the following way:

SA_ReadUncommitted = SQL_TXN_READ_UNCOMMITTED
SA_ReadCommitted = SQL_TXN_READ_COMMITTED
SA_RepeatableRead = SQL_TXN_REPEATABLE_READ
SA_Serializable = SQL_TXN_SERIALIZABLE

For more details see SAConnection::setIsolationLevel.

 

Working with Long or Lob(CLob, BLob) data

SQLAPI++ supports four types for working with Long or Lob(CLob, BLob) data:

Name C enum constant
LongBinary SA_dtLongBinary
LongChar SA_dtLongChar
BLob (Binary Large object) SA_dtBLob
CLob (Character Large object) SA_dtCLob

The table below shows how SQLAPI++ data types correspond with servers original data types:

SA_dtLongBinary <= > BYTE
SA_dtLongChar <= > TEXT
SA_dtBLob = > BYTE
SA_dtCLob => TEXT

For more details see How To - Working with Long or Lob(CLob, BLob) data

 

Returning output parameters

In Informixstored procedure can return zero or more values or sets of values through a result set. After calling SACommand::Executeuse SACommand::FetchNext loop to retrieve these values.

For more details see SACommand::Execute, SAParam object, How To - Returning Output Parameters.

 

Cancelling queries

Using SACommand::Cancel method you can cancel the following types of processing on a statement:

  • A function running asynchronously on the statement.
  • A function running on the statement on another thread.

SQLAPI++ calls SQLCancel function to cancel a query. To get more details see SQLCancel function description in Informix documentation.

For more details see SACommand::Cancel.

 

Connection, command, parameter and field options

A 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 Informix server:

Option name / Scope 

Description

INFCLI.LIBS

Connection related. Should be specified before the first connection is made.
Forces SQLAPI++ Library to use specified INFORMIX-CLI library.

Valid values : Any valid INFORMIX-CLI library name list. Names separated by ';' on Windows or ':' on other OS.
Default value: Windows - "ICLIT09B.DLL;ICLIT09A.DLL", Linux -  "libifcli.so:iclit09a.so:iclit09b.so".

UseDynamicCursor
or
Scrollable

Command related. Should be specified before describing parameters or command execution.
Forces SQLAPI++ to use scrollable dynamic command handle. Sets the command handle attributes SQL_ATTR_CURSOR_TYPE = SQL_CURSOR_DYNAMIC and SQL_ATTR_CONCURRENCY = SQL_CONCUR_LOCK. Make attention that the connection should be configured for scrollable cursor support.

Valid values: "True", "1". Default value: "false".

SetCursorName

Command related. Should be specified before describing parameters or command execution.
Allows to define the cursor name SQLAPI++ uses for the server side cursor.

Valid values:  See SQLSetCursorName documentation.
Default value: none.

ExecDirect

Command related. Should be specified before describing parameters or command execution.
Forces SQLAPI++ to use SQLExecDirect instead of SQLExecute API function.

Valid values: "True", "1". Default value: "false".

SQL_ATTR_QUERY_TIMEOUT

Command related. Should be specified before describing parameters or command execution.
Sets the integer value corresponding to the number of seconds to wait for an SQL statement to execute before returning to the application.

 

Getting native Informix API

You 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 Informix . 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 Informix API.

Type casting

Additional
include file

Cast the result to class infAPI:

saAPI *pResult = con.NativeAPI();
infAPI *p_infAPI = (infAPI *)pResult;

#include <infAPI.h>

To get more information about DBMS API functions see this DBMS specific documentation. 

For more details see SAConnection::NativeAPI.

 

Getting native Informix connection related handles

You have to use native API handles when you want to call specific Informix 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 Informix API.

Type casting

Cast the result to class infConnectionHandles:

#include <infAPI.h>

saConnectionHandles *pResult = con.NativeHandles();
infConnectionHandles *p_infCH =
                                (infConnectionHandles *)pResult;

Available handles:

  • SQLHENV m_hevn;
  • SQLHDBC m_hdbc;

To get more information about DBMS API functions and handles see this DBMS specific documentation. 

For more details see SAConnection::NativeHandles.

 

Getting native Informix command related handles

You have to use native API handles when you want to call specific Informix 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 Informix API.

Type casting

Cast the result to class infCommandHandles:

#include <infAPI.h>

saCommandHandles *pResult = cmd.NativeHandles();
infCommandHandles *p_infCH =
                                (infCommandHandles *)pResult;

Available handles:

  • SQLHSTMT m_hstmt;

To get more information about DBMS API functions and handles see this DBMS specific documentation. 

For more details see SACommand::NativeHandles.

 

Error handling

When an error occurs inside SQLAPI++ Library it throws an exception of type SAException. SAException::ErrPos method gets an error position in SQL statement. In Informix server SAException::ErrPos method returns -1 because Informix does not support this function..

For more details see How To - Error handling, SAException object.

 

Special header files - Compile time

The header files are in the include subdirectory of SQLAPI++ distributions:
#include <SQLAPI.h> - main header, should be used whenever SQLAPI++ is used.
#include <infAPI.h> - Informix API, should be included if direct informix CLI calls are required.

For more details see Online Documentation - Instructions for Compiling and Linking Applications with SQLAPI++ 


Problems and Questions

If 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.