Info Introduction and Files How to use the CLI Definitions and Common Data Types Data Qualifier FAR, NEAR Data Type BOOL Data Type CHAR, UCHAR Data Type DWORD, SDWORD, UDWORD Data Type HANDLE Data Type HWND Data Type LONG, ULONG Data Type PTR Data Type RETCODE Data Type SHORT, USHORT Data Type WORD, SWORD, UWORD Data Type INT Function Qualifier PASCAL Function Qualifier SQL_API Function Qualifier SQL_LOCAL_API Function Macro MAX, MIN SQL Data Types SQLAllocConnect SQLAllocEnv SQLAllocHandle SQLAllocStmt SQLBindCol SQLBindParam SQLBrowseConnect SQLCancel SQLCloseCursor SQLColAttributes SQLColumnPrivileges SQLColumns SQLConnect SQLCopyDesc SQLDescribeCol SQLDescribeParam SQLDisconnect SQLDriverConnect SQLDriverSetup SQLEndTran SQLError SQLExecDirect SQLExecute SQLExtendedFetch SQLFetch SQLForeignKeys SQLFreeConnect SQLFreeEnv SQLFreeHandle SQLFreeStmt SQLGetCol SQLGetConnectAttr SQLGetConnectOption SQLGetCursorName SQLGetData SQLGetDescField SQLGetDescRec SQLGetDiagField SQLGetDiagRec SQLGetEnvAttr SQLGetInfo SQLGetStmtAttr SQLGetStmtOption SQLGetTypeInfo SQLLanguages SQLMoreResults SQLNativeSql SQLNumParams SQLNumResultCols SQLParamData SQLParamOptions SQLPrepare SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLPutData SQLReleaseEnv SQLRowCount SQLServerInfo SQLSetConnectOption SQLSetCursorName SQLSetDescField SQLSetDescRec SQLSetEnvAttr SQLSetParam SQLSetPos SQLSetScrollOptions SQLSetStmtAttr SQLSetStmtOption SQLSpecialColumns SQLStatistics SQLTablePrivileges SQLTables SQLTransact CLI Function Return Codes Sample Sources iODBC Description of iODBC.INI Sample iODBC.INI for OS/2 Sample iODBC.INI for Unix Compatibility List Limitations and Differences to Standard CLI/ODBC Limits for mSQL Limits for Oracle History Author's Details Archive Location
intrinsic Open Data Base Connection (iODBC) for OS/2 * standardization of database access * |
All programs included in this package are provided "as is", without any warranty! Try them on your own risk. |
This documentation is based on various documentations and own expiriences.
(c) 1997 by Dirk Ohme - all rights reserved
Note: The Call Level Interface is an C-API for
writing portable database applications. It is meant to be database independent.
The sources are drawn a bit from ODBC (Open DataBase Connection - a firm
specific standard by the Microsoft Corporation based on X/Open's CLI) and CLI
specified by the ISO/ANSI comitee and X/Open.
Drivers (CLI) are located under the DRIVER directory.
Currently there are the following drivers:
The following Call-Level Interfaces (CLI) may be used as iODBC-compliant
ODBC drivers:
Within your programs, you have to include a file named sqlcli_.h.
This is normally done by insertion of a statement like this:
Make sure that this file is located to a directory normally being searched
for include files by the compiler or specify the directory containing this
file directly at compiler call (this is done by
/Idirectory for the IBM C compilers or by
-Idirectory for Unix style C compilers, e.g.
gcc, there directory is the desired directory).
Note: In order to link the compiled sources, use following files located in the
library directory (LIB) for
To use the CLI properly there is a predefined path showing when to call
which routine. The next picture describes a CLI session.
Transactions could be done in various ways. A transaction can store or
manipulate data (INSERT, UPDATE, DELETE, ...),
retrieve data (SELECT, ...) or do anything else (manipulation on
table structure, access control to data, creation of views, ...). The next
picture contains an overview on transaction operation:
This section contains the definitions used within the Call-Level
Interface as there set in sqlcli_.h. For better understanding,
notice, that (under OS/2!):
The purpose of this qualifiers is to specify if a pointer is used
within this data segment (NEAR) or not (FAR). Under
OS/2 2.x or above it is not necessary to use this.
Note: This defines a boolean data type with it's two possible values
This defines a data type for storing signed / unsigned integer values,
i.e. characters.
This defines a data type for storing signed / unsigned double words.
The purpose of this data type is to store a unqualified handle to
"anything".
The purpose of this data type is to store a handle for window manipulation.
This defines a data type for storing signed / unsigned long integer
values.
This data type is intended to be used for unqualified pointer
specification. It is comparable with the ANSI-C data type void *.
This data type is intended to be used to specify an unqualified
program return code, i.e. a return code of "something".
This defines a data type for storing signed / unsigned short integer
values.
This defines a data type for storing signed / unsigned words.
This defines a data type for storing unsigned integer values.
The intention of this function qualifier is to distinguish between
function with "C" and "PASCAL" parameter/calling convention. For
example:
This qualifier is used for specification of a public call-level
interface routine (procedure).
This qualifier is used for specification of a non-public (private)
call-level interface routine (procedure).
These macros can be used for checking two numbers (numerical values)
against. MAX returns the greater number, MIN the
minor number of the two given ones.
Accessing the database through the Call-Level Interface requires an
abstraction of the data types. The 'C' programming language and the structured
query language (SQL) have different names and types for certain data objects.
So there are data types defined in the header file sqlcli_.h for
interactions between 'C' code and SQL database.
First there are the following definitions (constants):
And now the SQL data types:
Note: Special structures used by the iODBC:
calling parameters
return codes
The call provides the allocation of a database context structure, that is
used for database connection and transactions. It takes the handle returned
by SQLAllocEnv() as
input parameter.
calling parameters
return codes
This function has to be called at start of the program in order to create a
environment where the CLI could work. phenv has to point to the
variable used as handle to the environment block.
Note: calling parameters
return codes
calling parameters
return codes
Allocation of a statement handle, which is used for database interactions
(queries, insertions, deletes, etc.). This function requires an open database
context handle. After the last interaction and before freeing the database
context, all allocated statement handles have to be closed via
SQLFreeStmt().
calling parameters
return codes
After execution of a query via SQLExecute() or SQLExecDirect() the results must be bound to
variables before a SQLFetch() call
for getting values can take place. This function bind a variable to a field or
column of the resulting table.
calling parameters
return codes
calling parameters
return codes
calling parameters
return codes
This function allows canceling of a database operation (INSERT, DELETE,
UPDATE), needing more input data. Such a situation may occur when
SQLExecute() or
SQLExecDirect() returns a
status SQL_NEED_DATA. Then this function can be called to cancel
the execution of the command in order to specify all missing data and re-do
the operation.
Note: calling parameters
return codes
calling parameters
return codes
This function returns various informations about the result columns of a
database query. Keep in mind, that each call of this function can return only
one answer. An alternative may be SQLDescribeCol().
calling parameters
return codes
calling parameters
return codes
calling parameters
Note:
All files (except iODBC) are copyrighted by Dirk Ohme, all other are under
GNU-law. You are allowed to use the CLI and all related stuff in
non-commerical environments without any fee. If you want to use the CLI
within a commerical environment, please contact the author. If you want to
use iODBC within a commercial environment, see the GNU law.
The archive may be distributed freely, but only as one package that
mustn't be modified to the original distribution!
Introduction and Files
How to use the CLI
/*
** use the next include for use of CLI or iODBC
** (contains function prototypes)
*/
#include <sqlcli_.h>
/*
** on iODBC as an alternative to the above include file
** you may use one or both of these include files
** (lacks most function prototypes)
*/
#include <isql.h>
#include <isqlext.h>
All environement dependend header files (i.e. msql.h for
mSQL) have to be put to a directory, for which the same conditions
exists (included during compilation per default or per parameter switch).
Definitions and Common Data Types
Data Qualifier FAR, NEAR
FAR
NEAR
This is implemented for migration of software from platforms, where the
determination of FAR and NEAR pointers is necessary.
Data Type BOOL
BOOL { FALSE, TRUE }
Data Type CHAR, UCHAR
CHAR - signed char
UCHAR - unsigned char
Data Type DWORD, SDWORD, UDWORD
DWORD - double word
SDWORD - signed double word
UDWORD - unsigned double word
Data Type HANDLE
HANDLE - (unqualified) handle
Data Type HWND
HWND - handle (for) window
Data Type LONG, ULONG
LONG - signed long integer
ULONG - unsigned long integer
Data Type PTR
PTR - (unqualified) pointer
Data Type RETCODE
RETCODE - (unqualified) program return code
Data Type SHORT, USHORT
SHORT - signed short integer
USHORT - unsigned short integer
Data Type WORD, SWORD, UWORD
WORD - word
SWORD - signed word
UWORD - unsigned word
Data Type INT
UINT - unsigned integer
Function Qualifier PASCAL
PASCAL
void funcProto(int a, int b ); /* C calling convention */
void PASCAL funcProto(int a, int b); /* PASCAL calling convention */
Function Qualifier SQL_API
SQL_API
Function Qualifier SQL_LOCAL_API
SQL_LOCAL_API
Function Macro MAX, MIN
MAX(x,y) ((x > y) ? x : y)
MIN(x,y) ((x < y) ? x : y)
SQL Data Types
SQL_DATE_LEN maximum length of date strings
SQL_MAX_DRV_ID_LENGTH maximum length of iODBC driver setup IDs
SQL_MAX_ID_LENGTH maximum length of identifiers
SQL_MAX_MESSAGE_LENGTH maximum length of messages
SQL_SQLSTATE_SIZE maximum length of status codes
SQL_TIME_LEN maximum length of time strings
SQL_TIMESTAMP_LEN maxmimum length of a timestamp
SQLPOINTER PTR
SQLRETURN RETCODE SQL_API
SQLUINTEGER UINT
SQLUSMALLINT USHORT
***SQL native*** identifier 'C' ***comment***
SQLBINARY SQL_C_BINARY unsigned char bit field of 8 bits
SQLBIT SQL_C_BIT BOOL
SQLBLOBLOCATOR SQL_C_BLOB_LOCATOR long reference
SQLCHAR SQL_C_CHAR unsigned char
SQLCLOBLOCATOR SQL_C_CLOB_LOCATOR long reference
SQLDATE - unsigned char pointer to string
SQLDBCHAR SQL_C_DBCHAR unsigned char character
SQLDBCLOBLOCATOR SQL_C_DBCLOB_LOCATOR long reference
SQLDECIMAL - unsigned char pointer to string
SQLDOUBLE SQL_C_DOUBLE double
SQLINTEGER SQL_C_LONG long
SQLFLOAT SQL_C_FLOAT float
SQLNUMERIC - unsigned char pointer to string
SQLREAL SQL_C_REAL float
SQLSCHAR SQL_C_TINYINT signed char
SQLSHORT SQL_C_SHORT short
SQLSMALLINT SQL_C_SHORT short
SQLTIME - unsigned char pointer to string
SQLTIMESTAMP - unsigned char pointer to string
SQLTINYINT SQL_C_TINYINT signed char
***SQL native*** identifier sub-entries ***comment***
SQLDATE SQL_C_DATE DATE_STRUCT date structure
year year
month month
day day
SQLTIME SQL_C_TIME TIME_STRUCT time structure
hour hour
minute minute
second second
SQLTIMESTAMP SQL_C_TIMESTAMP TIMESTAMP_STRUCT time stamp
year year
month month
day day
hour hour
minute minute
second second
fraction ???
***SQL*** Handle/Pointer 'C' ***comment***
SQLHDBC HDBC, LPDBC DBC CLI database context
SQLHDESC HDESC, LPDESC DESC CLI descriptor
SQLHENV HENV, LPENV ENV CLI environment
SQLHSTMT HSTMT, LPSTMT STMT CLI statement
BLOB stands for binary large object block.
CLOB stands for character large object block.
typedef struct _SQLDrvOptList { /* driver options list */
char szOptName[SQL_MAX_DRV_ID_LENGTH]; /* - option name */
char szOptValue[SQL_MAX_DRV_ID_LENGTH]; /* - option value */
void *pNext; /* - pointer to next element */
} SQLDrvOptList, *SQLPDrvOptList; /* */
typedef struct _SQLDriverList { /* driver list */
char szName[SQL_MAX_DRV_ID_LENGTH]; /* - name of driver */
SQLPDrvOptList pOptions; /* - start of options list */
void *pNext; /* - pointer to next element */
} SQLDriverList, *SQLPDriverList; /* */
SQLAllocConnect
RETCODE SQL_API SQLAllocConnect(
LPENV lpenv,
HDBC FAR *phdbc
);
ODBC core level
X/Open yes
return code SQLError comment
SQL_ERROR S1001 memory allocation error
S1009 invalid pointer phdbc
SQL_INVALID_HANDLE - invalid pointer lpenv
SQL_SUCCESS - context successfully allocated
SQLAllocEnv
RETCODE SQL_API SQLAllocEnv( SQLHENV FAR *phenv
);
ODBC core level
X/Open yes
return code SQLError comment
SQL_ERROR - internal error (memory problems?)
SQL_INVALID_HANDLE - invalid pointer phenv
SQL_SUCCESS - environment successfully allocated
There is no error message (see SQLError) available.
SQLAllocHandle
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
SQLAllocStmt
RETCODE SQL_API SQLAllocStmt(
LPDBC lpdbc,
HSTMT FAR *phstmt);
ODBC core level
X/Open yes
return code SQLError comment
SQL_ERROR S1001 memory allocation failure
S1009 invalid pointer phstmt
SQL_INVALID_HANDLE - invalid handle lpdbc
SQL_SUCCESS - statment handle created successfully
SQLBindCol
RETCODE SQL_API SQLBindCol(
LPSTMT lpstmt,
UWORD icol,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
SDWORD FAR *pcbValue);
ODBC core level
X/Open yes
return code SQLError comment
SQL_ERROR 07005 column icol not available
S1003 unsupported C data type in fCType
S1002 invalid column number icol
S1010 no query has been done or no results
S1090 result greater than allowed in cbValueMax
SQL_INVALID_HANDLE - invalid handle lpstmt
SQL_SUCCESS - no errors
SQLBindParam
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
SQLCancel
RETCODE SQL_API SQLCancel(
LPSTMT lpstmt);
ODBC core level
X/Open yes
return code SQLError comment
SQL_INVALID_HANDLE - invalid handle lpstmt
SQL_SUCCESS - no errors
This function is a dummy function at the current state. mSQL does not support
such things. It may support this in a later version.
SQLCloseCursor
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
ODBC core level
X/Open yes
In this implementation for numerical data types SQL_ALL_EXCEPT_LIKE
and for character data types SQL_SEARCHABLE will be returned.
In this implementation all columns are updateable.
return code SQLError comment
SQL_ERROR 07005 no result available for sub-function
40003 communication to database server failed
S1002 invalid column number icol
S1010 there are no results of a query to be examined
S1090 invalid pointer rgbDesc or pfDesc or length cbDescMax
S1091 invalid sub-function fDescType
S1C00 CLI can't resolve database server's answer
SQL_INVALID_HANDLE - invalid handle lpstmt
SQL_SUCCESS_WITH_INFO 01004 result string rgbDesc has been truncated
SQL_SUCCESS - no errors
SQLColumnPrivileges
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
ODBC
X/Open
return code SQLError comment
SQL_ERROR
SQL_INVALID_HANDLE -
SQL_SUCCESS -
ODBC core level
X/Open yes
This special implementation for mSQL may have a different use of
szDSN as known by other CLIs or ODBC. You may specify user
name, database name and host (system name or IP)
within this entry. Examples:
szDSN = <database name> "sample"
<user name>.<database name> "kim.sample"
<database name>@<host> "sample@minerva.edu.au"
<user name>.<database name>@<host> "kim.sample@127.0.0.1"
Note:
If a host isn't specified, a connection to the server on the local
machine (localhost) is tried to be established.
return codes
return code | SQLError | comment |
SQL_ERROR | 08001 | can't connect to server |
08002 | connection already established | |
08004 | can't connect to database | |
SQL_INVALID_HANDLE | - | invalid database context handle |
SQL_SUCCESS | - | connection established |
This function has to be called after
SQLAllocConnect(). It tries
to connect to a database source (mSQL: host/database). After
successful connection database activities may start.
SQLCopyDesc
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 07005 | column not available |
40003 | can't get column info from server | |
S1002 | invalid column number icol | |
S1010 | no query has been executed | |
S1097 | invalid column type detected | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no errors |
This routine can be used first to find out how many columns a query returns.
Second, it can be used to detect the type of columns.
SQLDescribeParam
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLDisconnect
RETCODE SQL_API SQLDisconnect(
LPDBC lpdbc
);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 08003 | no connection established |
25000 | transaction must be ended first | |
58004 | can't find path to database | |
SQL_INVALID_HANDLE | - | invalid handle to database context |
SQL_SUCCESS | - | connection successfully closed |
The purpose of this routine is to close an open connection established by
SQLBrowseConnect(),
SQLConnect() or
SQLDriverConnect(). After
successful close there can't be any database activities. Before closing, all
open transactions have to be ended (see
SQLTransact()).
SQLDriverConnect
RETCODE SQL_API SQLDriverConnect(
LPDBC lpdbc,
HWND hwnd,
UCHAR FAR *szConnStrIn,
SWORD cbConnStrIn,
UCHAR FAR *szConnStrOut,
SWORD cbConnStrOutMax,
SWORD FAR *pcbConnStrOutMax,
UWORD fDriverCompletion
);
ODBC | level 1 |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 08001 | can't connect to database server (host) |
08002 | already connected | |
08004 | can't connect to database (on host) | |
SQL_INVALID_HANDLE | - | invalid handle lpdbc |
SQL_SUCCESS | - | successful database login |
Comparable to SQLConnect(), but with more possibilities. If the given information is insufficient for database login, this routine may open a dialog window to give the user the possibility to complete the information. Further, the connection information is given by one string (no separate database, user name, password strings) - the structure is described above. The example above shows a connection information for login into a database testdb with user name master and password chief.
DSN=testdb;UID=master;PWD=chief
iODBC and OS/2 specific! |
RETCODE SQL_API SQLDriverSetup( LPDBC lpdbc, HWND hwnd, HMODULE hmod, SQLPDriverList pDrvEntry );
ODBC | no - iODBC & OS/2 specific |
X/Open | no |
calling parameters
return codes
return code | SQLError | comment |
SQL_INVALID_HANDLE | - | invalid lpdbc, hwnd, hmod or pDrvEntry |
SQL_SUCCESS | - | successful operation |
This is an iODBC specific function to able a driver special settings and
setups. I may not be implemented in order to get a full functioning driver.
But with this it is much easier to control certain behaviours and settings.
SQLEndTran
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_INVALID_HANDLE | - | invalid lpenv, lpdbc and lpstmt |
SQL_NO_DATA_FOUND | - | no more data or no previous error |
SQL_SUCCESS | - | data available |
Returns a message text for a previously occurred error. If there was no
previous error, SQL_NO_DATA_FOUND is returned. After successful
return of this function, all internal states are resetted.
SQLExecDirect
RETCODE SQL_API SQLExecDirect(
LPSTMT lpstmt,
UCHAR FAR *szSqlStr,
SDWORD cbSqlStr);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | xxxxx | see below |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no errors |
This call combines SQLPrepare()
with SQLExecute(). It may be used
if there are no parameters to be set between preparation and execution of a
statement. The error code are the same as described at the routines mentioned
above.
SQLExecute
RETCODE SQL_API SQLExecute(
LPSTMT lpstmt);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 08001 | cannot execute |
40003 | no connection to database | |
S1010 | no prepared statement found | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | execution ended successfully |
After preparation of a SQL statement with SQLPrepare() this function executes the statement.
Afterwards, on insertion or deletion SQLRowCount() returns the number of rows affected
by the operation, on selection SQLNumResultCols() shows the number of
selected rows, that can be queried by SQLDescribeCol(), SQLBindCol() and SQLFetch().
SQLExtendedFetch
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLFetch
RETCODE SQL_API SQLFetch(
LPSTMT lpstmt);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 22005 | error in data assignment |
58004 | can't get field (internal error) | |
S1010 | query must be executed first | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_NO_DATA_FOUND | - | no more results can be fetched |
SQL_SUCCESS | - | no errors |
The results of a query, executed via SQLExecute() or SQLExecDirect()., with variables bound by
SQLBindCol(), can be processed
row by row with this function. It copies the resulting fields (columns) into
the bounded variables.
SQLForeignKeys
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLFreeConnect
RETCODE SQL_API SQLFreeConnect(
LPDBC lpdbc
);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1010 | connection has to be closed first |
SQL_INVALID_HANDLE | - | invalid pointer lpdbc |
SQL_SUCCESS | - | context successfully freed |
After database operation this call has to be used to remove the database
context block. After successful removement SQLFreeEnv() can be called.
SQLFreeEnv
RETCODE SQL_API SQLFreeEnv( LPENV lpenv
);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1010 | connections have to be closed first |
SQL_INVALID_HANDLE | - | invalid pointer lpenv |
SQL_SUCCESS | - | environment successfully freed |
This function has to be called at the end of the program to free the CLI environment block. After successful removement of the environment block, the variable used for handle storage (input parameter lpenv) has to be invalidated.
Note:
After successfully freeing the CLI environment block, no error message can be
obtained through SQLError.
SQLFreeHandle
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLFreeStmt
RETCODE SQL_API SQLFreeStmt(
LPSTMT lpstmt,
UWORD fOption);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1092 | invalid option fOption |
SQL_INVALID_HANDLE | - | invalid lpstmt |
SQL_SUCCESS | - | operation succeeded |
Depending on the option code fOption a statement handle allocated
with SQLAllocStmt() is reseted
in parts or total, or is freed.
SQLGetCol
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1090 | parameter szCursor must not be NULL |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS_WITH_INFO | 01004 | cursor name was truncated |
SQL_SUCCESS | - | no errors |
This function returns the name of the cursor associated with the statement.
A new cursor name can be set by calling SQLSetCursorName().
SQLGetData
RETCODE SQL_API SQLGetData(
LPSTMT lpstmt,
UWORD icol,
SWORD fCType,
PTR rgbValue,
SDWORD cbValueMax,
SDWORD FAR *pcbValue)
ODBC | level 1 |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 07005 | column icol not available |
S1002 | invalid column number icol | |
S1003 | unsupported C data type in fCType | |
S1010 | no query has been done or no results | |
S1090 | result greater than allowed in cbValueMax | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no errors |
After execution of a query via SQLExecute() or SQLExecDirect() and after getting a resulting
row by a SQLFetch() call, the
column values can be gathered by this function.
SQLGetDescField
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLNumResultCols
RETCODE SQL_API SQLNumResultCols(
LPSTMT lpstmt,
SWORD FAR *pccol);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1009 | pccol must point to a variable |
S1010 | the query has to be executed first | |
SQL_INVALID_HANDLE | - | invalid pointer lpstmt |
SQL_SUCCESS | - | no errors |
After a successful execution of a query via SQLExecute(), the number of resulting columns can
be obtained by this function.
SQLParamData
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLPrepare
RETCODE SQL_API SQLPrepare(
LPSTMT lpstmt,
UCHAR FAR *szSqlStr,
SDWORD cbSqlStr);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 24000 | statement handle already in use |
S1001 | memory allocation error | |
S1009 | invalid pointer szSqlStr | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | preparation successfully |
Prepares a SQL statement for execution with SQLExecute().
SQLPrimaryKeys
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLRowCount
RETCODE SQL_API SQLRowCount(
LPSTMT lpstmt,
SWORD FAR *pcrow);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | S1009 | pcrow must point to a variable |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no error |
The number of rows affected by an UPDATE, INSERT or DELETE can be obtained with this function. For the number of rows returned by a SELECT have a look at SQLNumResultCols().
Note:
For the mSQL 1.x driver, this function is not behave absolutely identical to
the ANSI, ODBC or X/Open version. On UPDATE, INSERT or DELETE a value of
0 is always returned regardless the true number of rows affected.
On SELECT it returns the number of rows selected. The other drivers do behave
conforming to ANSI, ODBC and X/Open.
SQLServerInfo
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 34000 | invalid cursor name in szCursor |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no errors |
This is the reverse function to SQLGetCursorName(). It is used to set a new cursor name for the statement. A cursor name must start with a character (a..z or A..Z) and may then contain a mixture of characters, digits and underscores (a..z, A..Z, 0..9 or _).
Note:
Other implementations need unique cursor names and do not allow the re-use of
a cursor name, that has been already in use. This implementation does not
check cursor names for unique use, since cursor names are not being used
internally, but are implemented for compatibility.
Note:
Since there will be a unique cursor name created during allocation of the
statement handle (SQLAllocStmt()),
you may not use this function within your programs.
SQLSetDescField
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 07006 | can't convert C data type into SQL data type |
S1003 | invalid C data type in fCType | |
S1004 | invalid SQL data type in fSqlType | |
S1009 | rgbValue must not be NULL | |
S1010 | must be called after SQLPrepare() | |
S1013 | can't allocate internal memory | |
S1093 | invalid parameter number ipar | |
S1094 | invalid value in ibScale | |
S1104 | invalid value in cbColDef | |
S1C00 | unable to resolve the given C or SQL data type | |
SQL_INVALID_HANDLE | - | invalid handle lpstmt |
SQL_SUCCESS | - | no errors |
A parameter is a place holder in a SQL statement which is resolved at execution time (via SQLExecute()). A parameter is marked by a simple question mark ("?"). Question marks inside of strings delimited by single quotes ("'"). are not treated as parameter place holders but as characters. An example would be this:
select name, age from test where name='?^ or name=? |
select name, age from test where name='?^ or name='[contents of variable]' |
Note:
Character fields will be enclosed in single quotes automatically.
SQLSetPos
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
ODBC | |
X/Open |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | ||
SQL_INVALID_HANDLE | - | |
SQL_SUCCESS | - |
SQLTransact
RETCODE SQL_API SQLTransact(
LPENV lpenv,
LPDBC lpdbc,
UWORD fType);
ODBC | core level |
X/Open | yes |
calling parameters
return codes
return code | SQLError | comment |
SQL_ERROR | 08003 | no connection open for specified action |
58004 | SQL_ROLLBACK failed | |
S1012 | invalid action code fType | |
SQL_INVALID_HANDLE | - | handle lpenv or lpdbc must be set |
SQL_SUCCESS | - | no errors |
The purpose of the function is to commit or rollback (withdraw) database actions, like INSERT, UPDATE or DELETE. This function is called normally after (at the end of) a(n) (un)successful transaction.
Note: Each Call-Level Interface (CLI) function returns a result code, that
shows success or failure of an operation, or if there is additional information
code to be processed.
mSQL 1.x does not allow rollbacks on previous database actions. This is because
it does not have any recovery mechanism. For that reason all rollback
operations result in an error SQL_ERROR with message code
58004, to signalize an unsuccessful rollback.
CLI Function Return Codes
SQL_SUCCESS | operation ended successfully |
SQL_SUCCESS_WITH_INFO | same, but there is additional information (see table below) |
SQL_NEED_DATA | operation aborted due to lack of data |
SQL_NO_DATA | operation failed due to lack of data |
SQL_NO_DATA_FOUND | there is no data found |
SQL_ERROR | operation failed, see SQLError |
SQL_INVALID_HANDLE | invalid handle ( HDBC, HDESC, HENV, HSTMT ) |
Note:
The definition SQL_SUCCEEDED(x) can be used to
detect whether x specifies a return code of a successful operation
or not.
Internal error messages and codes (set at SQL_ERROR)
Code | Message |
01004 | result string has been truncated |
07005 | column or result value not available |
07006 | can't convert C data type into SQL data type |
08001 | can't connect to server, cannot execute |
08002 | connection already established |
08003 | no connection established |
08004 | can't connect to database |
24000 | statement handle already in use |
25000 | transaction must be ended first |
34000 | invalid cursor name |
40003 | no connection to database or communication error |
58004 | ROLLBACK failed or an other internal error |
S1001 | memory allocation error |
S1002 | invalid column number |
S1003 | invalid or unsupported C data type |
S1004 | invalid SQL data type |
S1009 | pointer must address a variable and mustn't be NULL |
S1010 | invalid sequence in function calls |
S1012 | invalid action code |
S1013 | can't allocate internal memory |
S1090 | parameter error (parameter must not be NULL, range error) |
S1091 | invalid sub-function specified |
S1092 | invalid option |
S1093 | invalid parameter number |
S1094 | invalid value |
S1097 | invalid column type detected |
S1104 | invalid value |
S1C00 | a parameter or result can't be resolved |
The sample sources directory contains of the following files:
Makefile | Makefile for building the programs, depending on the distribution (mSQL for OS/2, stand-alone) equals Makefile.OS2 or Makefile.UNX |
Makefile.OS2 | original Makefile for use with OS/2 and IBM C/C++ Set/2 or IBM Visual Age C++ |
Makefile.UNX | original Makefile for use with various UNIX OSs. |
README.TXT | file with the latest news about the sample sources |
monitor.c | simple SQL monitor written in C. Queries for a SQL statement, sends it to the server and shows the results. |
showtab.c | another C source. Like 'monitor', but returns additional information about the result columns. |
This and the following sections describe the intrinsic Open Data Base Connection (iODBC) package coming along with this.
The iODBC library ables multiple database environments without having the need to re-compile the sources. This is done by a so-called driver manager. The driver manager is a layer between application and iODBC driver, which may be a CLI library. The driver manager's task is to check a database connection string in order to call the proper iODBC driver.
If an application wants to connect to a database db_1, it does
it through the driver manager, which resolves the request by a configuration
file (iodbc.ini) telling that
connections to the database db_1 requires the driver
Driver_A. All further access goes via driver manager to the
driver A.
The file iODBC.INI is located
If is an ASCII file containing these elements:
Under OS/2 the iODBC interface has been successfully tested against
Under Unix the iODBC interface has been successfully tested against
Depending on the version of this CLI/ODBC implementation, there are
limitations and differences to the CLI or ODBC standard. Some of them, which
are common to all versions, are described below, others, unique to one
version, in the following sub-sections.
There are the following limits dependingless to the version:
Currently these SQL and C data types are supported for mSQL:
The implementation level of routines equals ODBC core level.
There are the following limits for mSQL for Unix and mSQL for OS/2:
Currently these SQL and C data types are supported for Oracle 7.x:
The implementation level of routines equals ODBC core level,
except SQLColAttributes() (see below).
There are the following limits for Oracle 7.xcolon.
iODBC has been ported to OS/2 from the Unix Freeware version
2.12. The mSQL 1.0.x and 2.0 CLI / iODBC drivers have
been developed by Dirk Ohme.
Over all, this is the history:
Call-Level Interface (CLI) and (i)ODBC drivers for mSQL 1.0.x and 2.0,
(i)ODBC driver manager and JDBC-ODBC bridge were written by:
The primary site for this product is:
Description of iODBC.INI
Sample iODBC.INI for OS/2
#=============================================================================#
# iodbc.ini (OS/2) #
#=============================================================================#
# #
# sample configuration file for iODBC #
# #
#-----------------------------------------------------------------------------#
# #
# a driver section is set up like this: #
# [<identifier>] #
# Driver = <path>/<name_of_dynamic_link_library> #
# DSN = <database_name> #
# #
# <identifier> ::= [A-za-z][A-Za-z0-9_]* #
# [default] ::= entry used, if no other data matches #
# #
# Trace = ON | On | on | 1 | OFF | Off | off | 0 #
# enable tracing of ODBC routines #
# Tracefile = stdout | stderr #
# output for trace information, either stdout or stderr #
# #
#=============================================================================#
[DB2]
Comment = sample entry for IBM DB2/2
Trace = Off
TraceFile= stderr
Driver = c:\sqllib\dll\db2cli.dll
DSN = test
[mSQL]
Comment = sample entry for Mini SQL 1.0.x
Trace = Off
TraceFile= stderr
Driver = ..\lib\libmsql.dll
DSN = test@localhost
[mSQL2]
Comment = sample entry for Mini SQL 2.0
Trace = Off
TraceFile= stderr
Driver = ..\lib\libmsql2.dll
DSN = test@localhost
[default]
Comment = default entry - used when no entry else matches
Trace = On
TraceFile= stderr
Driver = ..\lib\libmsql2.dll
DSN = Minerva@localhost
#=============================================================================#
# end of file #
#=============================================================================#
Sample iODBC.INI for Unix
#=============================================================================#
# iodbc.ini (Unix) #
#=============================================================================#
# #
# sample configuration file for iODBC #
# #
#-----------------------------------------------------------------------------#
# #
# a driver section is set up like this: #
# [<identifier>] #
# Driver = <path>/<name_of_dynamic_link_library> #
# DSN = <database_name> #
# #
# <identifier> ::= [A-za-z][A-Za-z0-9_]* #
# [default] ::= entry used, if no other data matches #
# #
# Trace = ON | On | on | 1 | OFF | Off | off | 0 #
# enable tracing of ODBC routines #
# Tracefile = stdout | stderr #
# output for trace information, either stdout or stderr #
# #
#=============================================================================#
[mSQL]
Comment = sample entry for Mini SQL 1.0.x
Trace = Off
TraceFile= stderr
Driver = ../lib/libclimSQL.so
DSN = test@localhost
[mSQL2]
Comment = sample entry for Mini SQL 2.0
Trace = Off
TraceFile= stderr
Driver = ../lib/libclimSQL2.so
DSN = test@localhost
[Oracle]
Comment = sample entry for Oracle 7.x database
Trace = Off
TraceFile= stderr
Driver = ../lib/libclioracle.so
DSN = test/test@testdb
[default]
Comment = default entry - used when no entry else matches
Trace = On
TraceFile= stderr
Driver = ../lib/libclimSQL2.so
DSN = Minerva@localhost
#=============================================================================#
# end of file #
#=============================================================================#
Compatibility List
Limitations and Differences to Standard CLI/ODBC
Limits for mSQL
Limits for Oracle
History
Author's Details
Dirk Ohme
Programmer at transtec AG
Tübingen, Germany
E-mail: Dirk.Ohme@transtec.de
Fidonet: 2:246/2001.9@fidonet
Archive Location
Host: www.fh-albsig.de (141.87.110.2)
URL: http://www.fh-albsig.de/~ohme
Files: FILES/iODBC*.zip (Zip 2.0.1 archive)
Note: OS/2 port