Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

This task is to give an example of an exception handling routine
and to "throw" a new exception.



Related task

   Exceptions Through Nested Calls


 
--#SET TERMINATOR @
 
BEGIN
 DECLARE numerator INTEGER DEFAULT 12;
 DECLARE denominator INTEGER DEFAULT 0;
 DECLARE RESULT INTEGER;
 DECLARE overflow CONDITION FOR SQLSTATE '22003' ;
 DECLARE CONTINUE HANDLER FOR overflow
   RESIGNAL SQLSTATE '22375'
   SET MESSAGE_TEXT = 'Zero division';
 IF denominator = 0 THEN
  SIGNAL overflow;
 ELSE
  SET RESULT = numerator / denominator;
 END IF;
END @
 