Skip to content

packages tree.get_caller_name

Jan Kvetina edited this page Oct 9, 2020 · 2 revisions

tree.get_caller_name

Repository spec: tree.get_caller_name, body: tree.get_caller_name


Signature

FUNCTION get_caller_name (
    in_offset           PLS_INTEGER     := 0,
    in_skip_this        BOOLEAN         := TRUE,
    in_attach_line      BOOLEAN         := FALSE
)
RETURN logs.module_name%TYPE;
Show code (29 lines)

FUNCTION get_caller_name (
    in_offset           PLS_INTEGER     := 0,
    in_skip_this        BOOLEAN         := TRUE,
    in_attach_line      BOOLEAN         := FALSE
)
RETURN logs.module_name%TYPE
AS
    module_name         logs.module_name%TYPE;
    offset              PLS_INTEGER                 := COALESCE(in_offset, 0);
BEGIN
    -- find first caller before this package
    FOR i IN 2 .. UTL_CALL_STACK.DYNAMIC_DEPTH LOOP
        module_name := UTL_CALL_STACK.CONCATENATE_SUBPROGRAM(UTL_CALL_STACK.SUBPROGRAM(i));
        --
        IF in_skip_this AND module_name LIKE $$PLSQL_UNIT || '.%' THEN
            CONTINUE;
        END IF;
        --
        IF offset > 0 THEN
            offset := offset - 1;
            CONTINUE;
        END IF;
        --
        RETURN module_name ||
            CASE WHEN in_attach_line THEN tree.splitter || UTL_CALL_STACK.UNIT_LINE(i) END;
    END LOOP;
    --
    RETURN NULL;
END;

Clone this wiki locally