This is a discussion on Reading package constant causes PLS-00452: Subprogram '<name>' violates its associated pragma within the Oracle Database forums, part of the Database Server Software category; --> The following simplied case demonstates how you may get PLS-00452: Subprogram '<name>' violates its associated pragma, when I would ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| The following simplied case demonstates how you may get PLS-00452: Subprogram '<name>' violates its associated pragma, when I would not have expected it. There is a single package with constants and a package with body, containing a function. CREATE OR REPLACE PACKAGE TEST_GLOB_CONST AS -- PRAGMA RESTRICT_REFERENCES(TEST_GLOB_CONST, WNDS); AConstant CONSTANT INTEGER := 1; END TEST_GLOB_CONST; / CREATE OR REPLACE PACKAGE TEST_PURITY AS FUNCTION Test RETURN INTEGER; PRAGMA RESTRICT_REFERENCES(Test, WNDS); END TEST_PURITY; / CREATE OR REPLACE PACKAGE BODY TEST_PURITY AS FUNCTION Test RETURN INTEGER IS BEGIN RETURN TEST_GLOB_CONST.AConstant; END; END TEST_PURITY; / Compiling PACKAGE BODY TEST_PURITY will fail with PLS-00452: Subprogram 'TEST' violates its associated pragma. This is because it reads a global constant from the package TEST_GLOB_CONST. If you uncomment the pragma in PACKAGE TEST_GLOB_CONST and compile all, that will succeed. Hope this will help anyone else who is staring at function calls in stead of global constant references for a cause of PLS-00452. Maybe this is well-known to some, but I did not come across it in documentation. Best regards, Roel Schreurs The Netherlands |