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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Can I call another function inside the package?

Re: Can I call another function inside the package?

From: Mark G <mgumbs_at_nospam.hotmail.com>
Date: Wed, 23 Jun 1999 13:40:31 +0100
Message-ID: <3770d372.0@145.227.194.253>

  1. Your exception when others was not letting the real error message filter up back to you so you never saw the real error problem which was.....

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

The reason why it worked when aaa was a stand-alone function is that the compiler can determine the 'purity' level of stand alone functions but not when it is part of a package.

2. You do not need returns in procedures.

3. Because of the nature of your for loop, you do not need to explicitly declare rec1 as a rowtype of the zt table, the loop handles that for you.

3. Because you are using a function in a sql statement, you have to declare a pragma
in the package body header for the. Look up pragma restrict references (and purity) in any good book.

This code should work...

CREATE OR REPLACE PACKAGE try AS
FUNCTION aaa (x IN NUMBER) RETURN number; pragma restrict_references(aaa, WNDS);

PROCEDURE rrr (Mm number) ;
END try;
/

CREATE OR REPLACE PACKAGE BODY try AS
FUNCTION aaa (x IN NUMBER) RETURN number IS BEGIN
   return (x+10);
END aaa;

PROCEDURE rrr(mm IN number) IS

   CURSOR ccur1 IS SELECT * FROM zt where c2=mm;

BEGIN
   FOR rec1 IN ccur1 LOOP
     insert into zt values(aaa(rec1.c1),rec1.c2);    END LOOP;    commit;
 END rrr;

END try;



Mark

<snip> Received on Wed Jun 23 1999 - 07:40:31 CDT

Original text of this message

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