Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PRAGMA RESTRICT_REFERENCES question

Re: PRAGMA RESTRICT_REFERENCES question

From: Spencer <spencerp_at_swbell.net>
Date: Thu, 25 Jan 2001 00:33:30 -0600
Message-ID: <yLPb6.146$at3.183991@nnrp3.sbc.net>

the reason i specify PRAGMA RESTRICT_REFERENCES is to allow package functions to be used in DML statements (e.g. SELECT )

in order to use a PL/SQL function in a DML statement, Oracle will check whether the function is guaranteed not to perform certain operations. Oracle will automatically check this for a "standalone" function, but not for functions in a "package".

the pragma restrict_references allows you to assert the purity level of the function, and that means that the package function can be used in DML statements.

don't think you can outsmart the PL/SQL compiler, though. it does check to see if the assertion is valid when the body is compiled.

you can check this easily by developing your own package which includes a simple function, for example:

my_tochar(ad_val IN DATE, as_format IN VARCHAR2) IS
BEGIN
  RETURN TO_CHAR(ad_val, as_format);
END; and test it by using the function in a DML statement, e.g.

SELECT mypackage.my_tochar(sysdate,'DD-MON-YY') FROM DUAL; try it again after adding the pragma restrict_references and recompiling.

HTH <gmei_at_my-deja.com> wrote in message news:94o76r$fv9$1_at_nnrp1.deja.com...
> Hi:
>
> Could someone tell me what is the "advantage" of using PRAGMA
> RESTRICT_REFERENCES, such as WNDS and WNPS, and why do you "want to" use
> it in certain case? I am reading this part in Steven Feuerstein's Oracle
> PL/SQL Programming book and would like to clarify it a bitter.
>
> Is there an example that one would want to use the PRAGMA in the package
> code and why?
>
> TIA.
>
>
> Sent via Deja.com
> http://www.deja.com/
>
Received on Thu Jan 25 2001 - 00:33:30 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US