-- debug.sql

CREATE OR REPLACE FUNCTION get_store_state 
  (st_num store.store_number%TYPE) RETURN CHAR
AS
  st store.state%TYPE;
BEGIN
  $IF $$DEBUG $THEN
    DBMS_OUTPUT.PUT_LINE('In ' || $$PLSQL_UNIT || ':' || $$PLSQL_LINE);
  $END
  SELECT state
    INTO st
    FROM store
   WHERE store_number = st_num;
  RETURN st;
END;
/

ALTER SESSION SET PLSQL_CCFLAGS = 'debug:true';
ALTER FUNCTION get_store_state COMPILE;

DECLARE
  st VARCHAR2(30);
BEGIN
  st := get_store_state(7);
END;
/

ALTER SESSION SET PLSQL_CCFLAGS = 'debug:false';
ALTER FUNCTION get_store_state COMPILE;

DECLARE
  st VARCHAR2(30);
BEGIN
  st := get_store_state(7);
END;
/
