   DECLARE ACTUAL_LOGGER ANCHOR DATA TYPE TO LOGDATA.CONF_LOGGERS.LOGGER_ID;
   DECLARE ACTUAL_LEVEL ANCHOR DATA TYPE TO LOGDATA.LEVELS.LEVEL_ID;
 
-  SET EXPECTED_LEVEL = NULL;
+  SET EXPECTED_LEVEL = 5;
   UPDATE LOGDATA.CONFIGURATION
     SET VALUE = '3'
     WHERE KEY = 'defaultRootLevelId';
   CALL LOGGER.DEACTIVATE_CACHE();
+  UPDATE LOGDATA.CONF_LOGGERS
+    SET LEVEL_ID = 4
+    WHERE LOGGER_ID = 0;
+  -- 28 niveles
   CALL LOGGER.GET_LOGGER('9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.'
     || '5.6.7', ACTUAL_LOGGER);
   SET EXPECTED_LOGGER = (SELECT MAX(LOGGER_ID)
       FROM LOGDATA.CONF_LOGGERS);
-  UPDATE LOGDATA.CONF_LOGGERS_EFFECTIVE
-    SET LEVEL_ID = 4
-    WHERE LOGGER_ID = 0;
-  SELECT LEVEL_ID INTO ACTUAL_LEVEL
-    FROM LOGDATA.CONF_LOGGERS
+  UPDATE LOGDATA.CONF_LOGGERS
+    SET LEVEL_ID = EXPECTED_LEVEL
+    WHERE LOGGER_ID = 0;
+  SELECT LEVEL_ID INTO ACTUAL_LEVEL
+    FROM LOGDATA.CONF_LOGGERS_EFFECTIVE
     WHERE LOGGER_ID = 0;
 
   CALL DB2UNIT.ASSERT_INT_EQUALS('Test37: 1Tests to update before limit',
     EXPECTED_LEVEL, ACTUAL_LEVEL);
 
   SELECT LEVEL_ID INTO ACTUAL_LEVEL
-    FROM LOGDATA.CONF_LOGGERS
+    FROM LOGDATA.CONF_LOGGERS_EFFECTIVE
     WHERE LOGGER_ID = EXPECTED_LOGGER;
 
   CALL DB2UNIT.ASSERT_INT_EQUALS('Test37: 2Tests to update before limit',

    SET VALUE = '5'
    WHERE KEY = 'defaultRootLevelId';
  CALL LOGGER.DEACTIVATE_CACHE();
  CALL LOGGER.GET_LOGGER('1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.'
    || '7.8.9.0', ACTUAL_LOGGER);
  SET EXPECTED_LOGGER = (SELECT MAX(LOGGER_ID)
      FROM LOGDATA.CONF_LOGGERS);
  UPDATE LOGDATA.CONF_LOGGERS_EFFECTIVE
    SET LEVEL_ID = 1
    WHERE LOGGER_ID = 0;
  UPDATE LOGDATA.CONF_LOGGERS
    SET LEVEL_ID = EXPECTED_LEVEL
    WHERE LOGGER_ID = 0;
  SELECT LEVEL_ID INTO ACTUAL_LEVEL
    FROM LOGDATA.CONF_LOGGERS
    WHERE LOGGER_ID = 0;

  CALL DB2UNIT.ASSERT_INT_EQUALS('Test39: 1Tests to update limit second update',
    EXPECTED_LEVEL, ACTUAL_LEVEL);

  SELECT LEVEL_ID INTO ACTUAL_LEVEL
    FROM LOGDATA.CONF_LOGGERS
    WHERE LOGGER_ID = EXPECTED_LOGGER;

  CALL DB2UNIT.ASSERT_INT_EQUALS('Test39: 2Tests to update limit second update',
    EXPECTED_LEVEL, ACTUAL_LEVEL);
  CALL DB2UNIT.ASSERT_INT_EQUALS('Test39: 3Tests to update limit second update',
    EXPECTED_LOGGER, ACTUAL_LOGGER);
 END @

-- Test40: Tests to update after limit second update.
CREATE OR REPLACE PROCEDURE TEST_40()
 BEGIN
  DECLARE EXPECTED_LOGGER ANCHOR DATA TYPE TO LOGDATA.CONF_LOGGERS.LOGGER_ID;

    SET VALUE = '5'
    WHERE KEY = 'defaultRootLevelId';
  CALL LOGGER.DEACTIVATE_CACHE();
  UPDATE LOGDATA.CONF_LOGGERS
    SET LEVEL_ID = 1
    WHERE LOGGER_ID = 0;
  -- 29 niveles
  CALL LOGGER.GET_LOGGER('0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.6.7.8.9.0.1.2.3.4.5.'
    || '6.7.8', ACTUAL_LOGGER);
  SET EXPECTED_LOGGER = (SELECT MAX(LOGGER_ID)
      FROM LOGDATA.CONF_LOGGERS);
  UPDATE LOGDATA.CONF_LOGGERS
    SET LEVEL_ID = EXPECTED_LEVEL
    WHERE LOGGER_ID = 0;
  SELECT LEVEL_ID INTO ACTUAL_LEVEL
    FROM LOGDATA.CONF_LOGGERS_EFFECTIVE
    WHERE LOGGER_ID = 0;

  CALL DB2UNIT.ASSERT_INT_EQUALS('Test38: 1Update limit',
    EXPECTED_LEVEL, ACTUAL_LEVEL);

  SELECT LEVEL_ID INTO ACTUAL_LEVEL
    FROM LOGDATA.CONF_LOGGERS_EFFECTIVE
    WHERE LOGGER_ID = EXPECTED_LOGGER;

  CALL DB2UNIT.ASSERT_INT_EQUALS('Test38: 2Update limit',
    EXPECTED_LEVEL, ACTUAL_LEVEL);
  CALL DB2UNIT.ASSERT_INT_EQUALS('Test38: 3Update limit',
    EXPECTED_LOGGER, ACTUAL_LOGGER);
 END @

-- Test39: Tests to update limit.
CREATE OR REPLACE PROCEDURE TEST_39()
 BEGIN
  DECLARE EXPECTED_LOGGER ANCHOR DATA TYPE TO LOGDATA.CONF_LOGGERS.LOGGER_ID;
