Table of Contents |
---|
SQLSTATE Variable
This variable is char[]-type and contains error and warning codes.
It is retained only for compatibility with SQL-89.
If you want to use it, write a code as follows.
Code Block | ||||
---|---|---|---|---|
| ||||
char SQLSTATE[6]; |
SQLState can be used for checking connection-state.
Code Block | ||||
---|---|---|---|---|
| ||||
char SQLSTATE[6]; ... if (memcmp (SQLSTATE, "08S01", 5) == 0 || memcmp (SQLSTATE, "08001", 5) == 0 || memcmp (SQLSTATE, "08003", 5) == 0 ) { // Handling Connection-Errors. ... } |
SQLCODE
This variable contains detailed error-code. user uses SQLCODE without declaring it.
Code Block | ||||
---|---|---|---|---|
| ||||
EXEC SQL INSERT INTO employee VALUES (...); if (sqlca.sqlcode != 0) printf("ErrCode = %d\n", SQLCODE); |
SQLCA
This is variable containing error and warning-code. user uses it without declaring it.
This is structure variable as follows.
- sqlca.sqlcode
Status codes
Description
0
Means that ALTIBASE HDB executed a statement without errors.
> 0
Means that ALTIBASE HDB executed a statement with some errors.
This occurs when SELECT statement without indicator-variable returned a result with NULL.< 0
Means that ALTIBASE HDB didn't execute a statement with some errors.
- sqlca.sqlerrm.sqlerrmc
It contains full-text error-messages. Its length is in sqlca.sqlerrm.sqlerrml
WJ
- sqlca.sqlerrd
It contains number of record processed. (ALTIBASE uses only sqlca.sqlerrd[2])
Pre-Defined Error-Code
SQLCODE | ALTIBASE HDB | ORACLE | Etc |
---|---|---|---|
(SQLCODE = 0) | SQL_SUCCESS | SQL_SUCCESS |
|
(SQLCODE = 1) | SQL_SUCCESS_WITH_INFO | SQL_SUCCESS_WITH_INFO |
|
(SQLCODE = -1) | SQL_ERROR | SQL_ERROR |
|
(SQLCODE = 100) | SQL_NO_DATA | SQL_NO_DATA |
|
(SQLCODE = -69720) | APRE_DUPKEY_ERROR | ORA-00001 |
|
You can refer to this document
WHENEVER
Code Block | ||||
---|---|---|---|---|
| ||||
EXEC SQL WHENEVER <condition> <action>; |
- Condition
The condition has two states. ALTIBASE HDB doesn't support "SQLWARNING".- SQLERROR
- NOTFOUND
- Action
- CONTINUE
- DO BREAK
- DO CONTINUE
- DO function_name
- GOTO label
- STOP
The connection is to be closed.
Some Notices
- APRE marks "EXEC SQL INCLUDE SQLCA" statement to a comment when precompiling it.
- APRE marks "#include <sqlca.h>" statement to a comment when precompiling it.