+ EXIT +
+ UNDO +
> SQL procedure statement |
When DB2 raises a condition that matches a condition, DB2 passes control to
the condition handler. The condition handler performs the action indicated by
handler type
, and then executes SQL procedure statement.
DB2 provides three general conditions:
NOT FOUND:
Identifies any condition that results in an SQLCODE of +100 or an SQLSTATE
beginning with the characters `02'.
SQLEXCEPTION:
Identifies any condition that results in a negative SQLCODE.
SQLWARNING:
Identifies any condition that results in a warning condition (SQLWARN0 is
`W'), or that results in a positive SQL return code other than +100. The
corresponding SQLSTATE value will begin with the characters `01'.
You can also use the DECLARE statement to define your own condition for a
specific SQLSTATE.
Example 7 53 shows the general flow of the condition handler in a stored
procedure.
Example 7 53 General example for condition handling
Begin
declare exit handler
for sqlexception
begin
statement3;
statement4;
end;
statement1;
statement2;
End
Example 7 54 shows a CONTINUE handler for delete and update operations on
a table named EMP. Again, please note that this code is intended for illustration
only.
220
MySQL to DB2 UDB Conversion Guide
footer
Our partners:
PHP: Hypertext Preprocessor Cheap Web Hosting
JSP Web Hosting
Ontario Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Java Hosting
Cheapest Hosting
Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved