Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Can I call another function inside the package?
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;
<snip> Received on Wed Jun 23 1999 - 07:40:31 CDT