Whenever an SQL statement executes, the SQLCODE and SQLSTATE
fields of the SQLCA receive a return code. Although both fields indicate whether
the statement executed successfully, they have some differences.
DB2 returns the following codes in SQLCODE:
SQLSTATE allows an application program to check for errors in the same way for different IBM database management systems. An advantage to using the SQLCODE field is that it can provide more specific information than can SQLSTATE.
Many of the SQLCODEs have associated tokens in the SQLCA that indicate, for example, which object incurred an SQL error. The advantage of SQLSTATE is its cross-vendor usability.
To conform to the SQL standard, the SQLCODE and SQLSTATE fields (SQLCOD and SQLSTA in FORTRAN) can be declared as standalone host variables.
If the STDSQL(YES) precompiler option is specified, these host variables receive the return codes, and the SQLCA does not need to be included in the program.
DB2 returns the following codes in SQLCODE:
- If SQLCODE = 0, execution was successful.
- If SQLCODE > 0, execution was successful with a warning.
- If SQLCODE < 0, execution was not successful.
- If SQLCODE = 100, no data was found.
SQLSTATE allows an application program to check for errors in the same way for different IBM database management systems. An advantage to using the SQLCODE field is that it can provide more specific information than can SQLSTATE.
Many of the SQLCODEs have associated tokens in the SQLCA that indicate, for example, which object incurred an SQL error. The advantage of SQLSTATE is its cross-vendor usability.
To conform to the SQL standard, the SQLCODE and SQLSTATE fields (SQLCOD and SQLSTA in FORTRAN) can be declared as standalone host variables.
If the STDSQL(YES) precompiler option is specified, these host variables receive the return codes, and the SQLCA does not need to be included in the program.
No comments:
Post a Comment