ORA-06571: Function CALC_AVG does not guarantee not to update database

ORA-06571: Function CALC_AVG does not guarantee not to update database

Post by Dean » Sun, 31 Dec 1899 09:00:00



I have written this as a function and as a package.  The function works
just fine, but when I try to call the same function within a package I
get this error.  Any Suggestons?  There is nothing but select statemnts
in the function just calculating an average against criteria that I can
use in a view.

Function CALC_AVG (CTID in varchar2, ASSAYTR in varchar2, ATYPE in
varchar2)

return number

is

TRP_AVG NUMBER(8,3);

BEGIN

 select avg(decode(operator,'=',result,null))

into

 TRP_AVG

from

 secondary_results

where

 assayid = ASSAYTR and
 sampleid = CTID and
 datatype = ATYPE;

return (TRP_AVG);

 
 
 

ORA-06571: Function CALC_AVG does not guarantee not to update database

Post by TurkBe » Sun, 31 Dec 1899 09:00:00


You need to add a pragma statement to your package spec...

In your case, it would be :

After the return statement ( at the end of the proc),
add

pragma restrict_references(CALC_AVG,RNDS,WNDS,WNPS);

Or something like that...see the reference manual about the pragma statements...


>I have written this as a function and as a package.  The function works
>just fine, but when I try to call the same function within a package I
>get this error.  Any Suggestons?  There is nothing but select statemnts
>in the function just calculating an average against criteria that I can
>use in a view.

>Function CALC_AVG (CTID in varchar2, ASSAYTR in varchar2, ATYPE in
>varchar2)

>return number

>is

>TRP_AVG NUMBER(8,3);

>BEGIN

> select avg(decode(operator,'=',result,null))

>into

> TRP_AVG

>from

> secondary_results

>where

> assayid = ASSAYTR and
> sampleid = CTID and
> datatype = ATYPE;

>return (TRP_AVG);

  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----

 
 
 

ORA-06571: Function CALC_AVG does not guarantee not to update database

Post by Thomas Kyt » Sun, 31 Dec 1899 09:00:00



(if that email address didn't require changing)


>I have written this as a function and as a package.  The function works
>just fine, but when I try to call the same function within a package I
>get this error.  Any Suggestons?  There is nothing but select statemnts
>in the function just calculating an average against criteria that I can
>use in a view.

packaged functions in all versions of Oracle before Oracle8i, release 8.1, must
specify their purity.

In the package specification, immediately after the prototype for this function
put:

  pragma restrict_references( calc_avg, wnds, wnps, rnps );

to specify that is:

WNDS - writes no database state (eg: no inserts)
WNPS - writes no package state
RNPS - reads no package state

Since it does RNDS (reads the database state) we'll leave that out.....

Quote:>Function CALC_AVG (CTID in varchar2, ASSAYTR in varchar2, ATYPE in
>varchar2)

>return number

>is

>TRP_AVG NUMBER(8,3);

>BEGIN

> select avg(decode(operator,'=',result,null))

>into

> TRP_AVG

>from

> secondary_results

>where

> assayid = ASSAYTR and
> sampleid = CTID and
> datatype = ATYPE;

>return (TRP_AVG);

--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st


Oracle Service Industries     Reston, VA   USA

Opinions are mine and do not necessarily reflect those of Oracle Corporation

 
 
 

ORA-06571: Function CALC_AVG does not guarantee not to update database

Post by Dean » Sun, 31 Dec 1899 09:00:00


Thanks,

Worked beautifully.

Rick


> You need to add a pragma statement to your package spec...

> In your case, it would be :

> After the return statement ( at the end of the proc),
> add

> pragma restrict_references(CALC_AVG,RNDS,WNDS,WNPS);

> Or something like that...see the reference manual about the pragma statements...


> >I have written this as a function and as a package.  The function works
> >just fine, but when I try to call the same function within a package I
> >get this error.  Any Suggestons?  There is nothing but select statemnts
> >in the function just calculating an average against criteria that I can
> >use in a view.

> >Function CALC_AVG (CTID in varchar2, ASSAYTR in varchar2, ATYPE in
> >varchar2)

> >return number

> >is

> >TRP_AVG NUMBER(8,3);

> >BEGIN

> > select avg(decode(operator,'=',result,null))

> >into

> > TRP_AVG

> >from

> > secondary_results

> >where

> > assayid = ASSAYTR and
> > sampleid = CTID and
> > datatype = ATYPE;

> >return (TRP_AVG);

>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----

 
 
 

1. ORA-06571: Function USER_DEF_CASE does not guarantee not to update database

Hi

I wrote a function called user_def_case.i want to call this function
in select statement.

Example: SELECT user_def_case(1500,1,'0_2000') from dual;

I am getting the following error.

ORA-06571: Function USER_DEF_CASE does not guarantee not to update
database

Inside function i want to insert errors into error_log table in
exception handler if function fails due to data problem.If i remove
this insert statement in exception handler section it will work.I saw
posted messages related to this error.They suggested use pragram
wnds.but it will not solve my problem.If i put this pragma wnds,it
will not write errors into error_log table.I want to write errors into
error_log table.Please help me,how to solve this problem.i am using
oracle 8.0.5.

Sagar

2. Database : "View" Concept ?

3. ORA-06571 function name does not guarantee not to update database: pragma

4. Which Replication strategy?!

5. ORA-06571: Function MYFUNC does not guarantee not to update database

6. pgsql/ /configure.in /configure rc/Makefile.gl ...

7. ORA-06571: Function does not guarantee not to update database

8. Error: An object was open??

9. ORA-06571: Function FN_SUP does not guarantee not to update database

10. Error - does not guarantee not to update database problem

11. Not guarantee not to update database

12. ORA-06571 from user defined function