SQLCODE Variable
The SQLCODE variable is an integer whose value indicates the success or failure of the most recently executed SQL statement.
Table 2–5 shows the SQLCODE return code values and their meanings.
Table 2–5: SQLCODE Return Code Values Return Code Meaning 0 The statement executed successfully and no exceptional conditions occurred. +1001 No rows were found to satisfy the request (see Table 2–6). < 0 An error occurred. For example, an update operation violated a specified constraint, such as NOT NULL or UNIQUE. See Table 2–7 for the individual error codes and meanings.
Table 2–6 shows the meaning of a +100 return code for each SQL statement where this return code can occur.
Table 2–6: Meanings of the +100 Return Code Statement Meaning FETCH There is no next row. SELECT
INSERT . . . SELECT There are no rows to select. Searched UPDATE1 No rows were found to update. Searched DELETE1 No rows were found to delete.
Table 2–7 lists and describes the specific error code values for SQLCODE.
Using SQLCODE in an Application
If you are using the SQL preprocessor, you declare a variable named SQLCODE as a long C within the scope of any function that contains any Progress/ESQL statements except the WHENEVER, BEGIN DECLARE SECTION, or END DECLARE SECTION statements:
You receive source code compilation errors if you do not declare the SQLCODE variable as a long C data type. You do not have to declare it within the SQL DECLARE SECTION of your application. However, it is recommended that you do so.
The SQL preprocessor uses the address of this declared variable as an argument to an ESQL-LIB function,
sqlcdbind()
. By placing this function call prior to many of the calls to the ESQL-LIB interface in the generated output, the SQL preprocessor notifies the interface where to deposit the status information.If you are not using the SQL preprocessor, or if you are using it and are accessing some of the ESQL-LIB functions that have no counterpart in Embedded SQL (especially the dynamic ESQL-LIB functions), you may still use SQLCODE as the mechanism to retrieve status information about the ESQL-LIB function calls being made. In this case, you declare a long C integer in your application and pass the address of that variable to the
sqlcdbind()
function. You do not have to declare the variable with the name SQLCODE.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |