CREATE OR REPLACE PACKAGE mip_debug IS

  -- Author  : HARDYA
  -- Created : 06/03/2008 09:07:01
  -- Purpose : provide debug output functionality

  PROCEDURE pl(p_unit IN VARCHAR2
              ,p_in   VARCHAR2
              ,p_line IN NUMBER DEFAULT NULL);
END mip_debug;
/
CREATE OR REPLACE PACKAGE BODY mip_debug IS

  PROCEDURE pl(p_unit IN VARCHAR2
              ,p_in   VARCHAR2
              ,p_line IN NUMBER DEFAULT NULL) IS
    l_fh     utl_file.file_type;
    l_output VARCHAR2(4000);
  BEGIN
  
    dbms_application_info.set_module(p_unit
                                    ,p_line || ':' || p_in);
    l_fh := utl_file.fopen(location  => 'WEBMIP_BULK_LOAD'
                          ,filename  => p_unit || replace(v('SYSTEM_ENVIRONMENT'),' ','_')||'_debug.txt'
                          ,open_mode => 'A');
  
    l_output := v('APP_SESSION')||':'||to_char(SYSDATE
                       ,'DD/MM/YYYY HH24:MI:SS') || ':' ||p_unit || ':' ||
                p_line || ':' || p_in;
  
    utl_file.put_line(l_fh
                     ,l_output);
    utl_file.fclose(l_fh);
  
    dbms_output.put_line(l_output);
  
  END pl;

BEGIN
  -- Initialization
  NULL;
END mip_debug;
/
