 SET RAISED_LG001 = FALSE;
 SET RAISED_724 = FALSE;
 DELETE FROM LOGDATA.CONF_LOGGERS WHERE LOGGER_ID <> 0;
-DELETE FROM LOGDATA.CONF_LOGGERS_EFFECTIVE WHERE LOGGER_ID <> 0;
 UPDATE LOGDATA.CONF_LOGGERS
   SET LEVEL_ID = 5
   WHERE LOGGER_ID = 0;

  END IF;
 END @

BEGIN
-- Reserved names for errors.
DECLARE SQLCODE INTEGER DEFAULT 0;
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';

DECLARE RAISED_LG001 BOOLEAN DEFAULT FALSE; -- Just one ROOT.
DECLARE RAISED_724 BOOLEAN DEFAULT FALSE; -- Null value.
DECLARE ACTUAL ANCHOR DATA TYPE TO LOGDATA.LOGS.MESSAGE;
DECLARE EXPECTED ANCHOR DATA TYPE TO LOGDATA.LOGS.MESSAGE;
-- Controlled SQL State.
DECLARE CONTINUE HANDLER FOR SQLSTATE 'LG001'
  BEGIN
   INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (5, 'SQLState ' || SQLSTATE);
   SET RAISED_LG001 = TRUE;
  END;
DECLARE CONTINUE HANDLER FOR SQLSTATE '54038'
  BEGIN
   INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (5, 'SQLState ' || SQLSTATE);

-- Test11: Limit passed logging to ROOT with warn.
INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (3, 'Test11: Limit passed logging to ROOT with warn');
SET EXPECTED = 'TRUE';
SET CASCADE = MIN_61;
CALL LOGGING(1, 3, CASCADE);
IF (RAISED_LG001 = FALSE) THEN
 INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (3, 'Exception not raised LG001');
ELSE
 INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (5, 'Exception raised LG001');
END IF;
SET RAISED_LG001 = FALSE;
SELECT 'TRUE' INTO ACTUAL
  FROM LOGS
  WHERE MESSAGE LIKE 'LG001. Cascade call limit achieved, for WARN: (0) Cascade call for "LOGGING" en%'
  AND DATE = (SELECT MAX(DATE) FROM LOGDATA.LOGS);
IF (EXPECTED <> ACTUAL) THEN
 INSERT INTO LOGDATA.LOGS (LEVEL_ID, MESSAGE) VALUES (2, 'Different MESSAGE ' || EXPECTED || ' - ' || ACTUAL);
END IF;
