| United States-English |
|
|
|
![]() |
Up and Running with ALLBASE/SQL: HP 3000 and HP 9000 Computer Systems > Chapter 4 Building an ALLBASE/SQL\COBOL Application in MPE/iXAdding an Explicit Error Checking Routine |
|
In most applications, it is useful to include a general-purpose exception handling routine to check the result of an SQL statement and to display ALLBASE/SQL error messages if something unexpected happens. ALLBASE/SQL uses the convention of setting the value of SQLCODE to zero when no error occurs, to 100 when no rows were found in a query, or to a negative number whenever an error or serious problem occurs in any SQL statement. You can build a routine that tests SQLCODE following each SQL statement, and you can use the SQLEXPLAIN statement to display error messages when SQLCODE is negative. The following sections show an example.
Before you can test the S100-SQL-STATUS-CHECK routine, you need to create an error condition that can be reported by the application. Use the following procedure to create the conditions for a runtime error:
You create the conditions for a runtime error by dropping the unique index on the Albums table, then entering duplicate key values (two rows with an AlbumCode of 3001) into the table. Inserting a duplicate key value (3001) will result in an error in the SELECT statement in the application, since a SELECT with an INTO clause requires a single-row query result.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||