PROCEDURE WRITE
( p_text IN VARCHAR2
, p_file IN VARCHAR2 DEFAULT ‘d_log.log’
, p_action IN VARCHAR2 DEFAULT ‘A’
, p_log_table IN BOOLEAN DEFAULT FALSE
, p_log_status IN VARCHAR2 DEFAULT ‘SUCCESS’
) IS
v_log utl_file.file_type;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
v_log := utl_file.fopen( ‘LOG’
, p_file
, p_action
);
utl_file.put_line( v_log
, TO_CHAR(SYSDATE,’YYYY-MM-DD HH24:MI:SS’) || ‘ ‘ || p_text
);
utl_file.fclose( v_log );
IF p_log_table
THEN
INSERT INTO dwfacts.batch_log
( log_date
, log_text
, log_status
)
VALUES ( SYSDATE
, p_text
, p_log_status
);
COMMIT;
END IF;
END WRITE