The c-treeSQL Communications AreaThe ESQL tool provides the error handling facility by returning the status code for every ESQL executable statement. The status code is returned in the c-treeSQL Communications Area (SQLCA). The SQLCA contains information about the status of the execution of the most recently executed c-treeSQL statement. The SQLCA is a structure with components that give additional information on the status of execution. The SQLCA includes information such as:
For example, the application can check to see whether an c-treeSQL statement executed successfully, and if so, how many rows were inserted or updated. Hence, the SQLCA gives an application developer the option of taking different actions, based on feedback obtained about the work just attempted. The two most frequently used SQLCA components are: SQLCODE This component holds a status code after the execution of every executable c-treeSQL statement. The SQLCODE is of long type that indicates the success or failure of the statement execution. A zero value returned in SQLCODE indicates a successful execution. A negative SQLCODE indicates an error in the c-treeSQL statement execution. A positive SQLCODE indicates a successful execution with a status code. Currently, the only positive status code is SQL_NOT_FOUND which is returned when there are no more rows to be fetched. SQLWARN This component is a character array of size eight where each array element is set to the warning flag, ‘W’ or a blank. The first element, SQLWARN[0], is set to ‘W’, if any of the other flags is set, and so indicates that a warning has occurred during the execution. An alternative way of handling errors is by using the WHENEVER statement. The WHENEVER statement allows an application developer to take specific actions under cases of exceptions. The exception cases could be, NOT FOUND, SQLERROR or SQLWARNING. The actions can include stopping the program, branching, or continuing with the execution. For more information on error handling refer to "Error Handling in ESQL". |
|||