
CREATE OR REPLACE Function utility.logging_test ()
RETURNS integer AS $$
-- Write error codes and messages to the audit table 
-- and write out a message to DBMS_OUTPUT
-- USAGE: "select utility.logging_test();"
DECLARE 
   p_log_yn 	CHAR = 'N';
   p_component 	VARCHAR(100) := 'Overpayment'; 
   p_function 	VARCHAR(100) := 'Create TLI'; 
   p_note  	VARCHAR(100);
   p_sql  	VARCHAR(100);
   p_dummy	INTEGER;
BEGIN

   -- LOG_MSG test (no log test)
   p_log_yn := 'n';
   p_note := 'Starting to create TLI';
   p_sql := 'INSERT INTO TLI...';
   PERFORM utility.LOG_MSG (p_log_yn, p_component, p_function, p_note, p_sql);

   -- LOG_MSG test
   p_log_yn := 'y';
   p_note := 'Created TLI';
   p_sql := 'INSERT INTO TLIA...';
   PERFORM utility.LOG_MSG (p_log_yn, p_component, p_function, p_note, p_sql);

   
   -- LOG_ERROR test (no log test)
   p_log_yn := 'n';
   p_note := 'Exception occurred while Starting to create TLI';
   p_sql := 'INSERT INTO TLI...';
   PERFORM utility.LOG_ERROR (p_log_yn, p_component, p_function, p_note, p_sql);
 
   -- LOG_ERROR test
   p_sql := 'INSERT INTO TLI...';
   -- Cause a handled exception to be raised 
   BEGIN
	SELECT col1 from xyz INTO p_dummy;
   EXCEPTION
	WHEN OTHERS THEN
	   p_log_yn := 'y';
           p_note := 'Exception occurred while Starting to create TLI';
	   PERFORM utility.LOG_ERROR (p_log_yn, p_component, p_function, p_note, p_sql);
   END;
   RETURN 0;
END;
$$ LANGUAGE plpgsql;