PLSQL Conditional Compilation With Debugging
Conditional compling can be used to show and hide debugging data based on PLSQL_CCFLAGS setting as shown below (false to hide and true to display data). It can customized to do event logging and tracing. The variables used for debugging can also be included or excluded using the PLSQL_CCFLAGS setting.

DECLARE
   max_flag BOOLEAN := FALSE;
   counter PLS_INTEGER := 0;
 
$IF $$debug_mode $THEN
   v_start PLS_INTEGER := DBMS_UTILITY.get_time;
   v_time PLS_INTEGER := 0;
$END
 
BEGIN
   DBMS_OUTPUT.PUT_LINE(' Start Time -> '||TO_CHAR(SYSDATE,'mm/dd/yyyy hh24:mi:ss'));
   WHILE max_flag != TRUE
   LOOP
   counter := counter + 1;
 
$IF $$debug_mode $THEN
    IF MOD(counter,25000) = 0 THEN
      v_time := DBMS_UTILITY.get_time - v_start;
      DBMS_OUTPUT.PUT('Time -> ['||TO_CHAR(v_time)||' ms] ['||TO_CHAR(v_time/1000)||' s] ');
      DBMS_OUTPUT.PUT_LINE(' Loaded -> '||LPAD(counter,6,' '));
    END IF;
$END
 
   max_flag := (counter > 100000); -- boolean check
   END LOOP;
    DBMS_OUTPUT.PUT_LINE(' End Time -> '||TO_CHAR(SYSDATE,'mm/dd/yyyy hh24:mi:ss'));
END;
/


ALTER SESSION SET PLSQL_CCFLAGS='debug_mode:TRUE';



ALTER SESSION SET PLSQL_CCFLAGS='debug_mode:FALSE';




Back



Last Revised on: November 03, 2013

  70016