Unix Technical Forum

Reading package constant causes PLS-00452: Subprogram '<name>' violates its associated pragma

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 ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 01:50 PM
schreurs_roel@hotmail.com
 
Posts: n/a
Default Reading package constant causes PLS-00452: Subprogram '<name>' violates its associated pragma

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com