Package Initialization Blocks
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
An unnamed block at the end of a package body that runs once per session, before the first real call.
How it works
A package body can end with its own unnamed BEGIN...END block, placed after all the procedure and function bodies — this runs exactly once per session, the first time anything in the package is referenced, before that first call actually executes. It's the standard place to prime package-level variables (load a lookup value, start a session-scoped timer) without requiring every caller to remember to invoke a separate 'init' procedure.
How it works
CREATE OR REPLACE PACKAGE BODY session_ctx AS
PROCEDURE set_user(p_user_id NUMBER) IS
BEGIN
g_current_user_id := p_user_id;
END;
BEGIN
-- Initialization block: runs once, the first time this package
-- is referenced in the session.
g_current_user_id := -1; -- 'not yet set' sentinel
END session_ctx;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.