SQLError
SQLError#
SQLError returns error or status information.
SQLErrorW() as a Unicode string supports same execution as SQLError().
Syntax#
SQLRETURN SQLError (
SQLHENV env,
SQLHDBC dbc,
SQLHSTMT stmt,
SQLCHAR * state,
SQLINTEGER * err,
SQLCHAR * msg,
SQLSMALLINT msgMax,
SQLSMALLINT * msgLength );
Arguments#
Data Type | Argument | In/Output | Description |
---|---|---|---|
SQLHENV | env | Input | Environment handle |
SQLHDBC | dbc | Input | Connection handle |
SQLHSTMT | stmt | Input | Statement handle |
SQLCHAR * | state | Output | Pointer of SQLSTATE |
SQLINTEGER * | err | Output | Pointer of unique Altibase error code |
SQLCHAR * | msg | Output | Pointer of the diagnosis message |
SQLSMALLINT | msgMax | Input | The character number of the *msg buffer |
SQLSMALLINT * | msgLength | Output | Pointer of the total length of return buffer. Excludes NULL termination character. |
Return Values#
SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR
Description#
SQLSTATE is the same as defined by X/OPEN SQL CAE and X/OPEN SQLCLI snapshot.
SQLERROR() gets diagnosis information as followings:
To gain environment-related diagnosis information, send a valid environment handle. Set dbc and stmt as SQL_NULL_DBC and SQL_NULL_STMT.
To acquire connection-related diagnosis information, send the valid database connection handle and set stmt as SQL_NULL_STMT. Arguments env will be ignored.
To acquire diagnosis information related to a command, send the valid statement handle. env and dbc Arguments will be ignored.
If diagnosis information created by one Altibase CLI function is not catched before functions other than SQLERROR() are called by the same handle, information related to calling of the previous functions will be lost. Always true regardless whether there is diagnosis information created by the second calling of the Altibase CLI function.
To prevent the error message from being cut, the buffer length will be declared as SQL_MAX_MESSAGE_LENGTH + 1. The message text cannot be longer than this.
Example#
< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_ex6.cpp >
SQLINTEGER errNo;
SQLSMALLINT msgLength;
SQLCHAR errMsg[MSG_LEN];
if (SQLError ( SQL_NULL_HENV, aCon, aStmt,
NULL, &errNo,
errMsg, MSG_LEN, &msgLength ) == SQL_SUCCESS)
{
printf(" Error : # %ld, %s\n", errNo, errMsg);
}