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: OK... maybe I'm being stupid... HELP

Re: OK... maybe I'm being stupid... HELP

From: <psinden_at_my-deja.com>
Date: Wed, 14 Jul 1999 02:30:11 GMT
Message-ID: <7mgsn7$5dj$1@nnrp1.deja.com>


You will need to add a
pragma restrict_references( HOWMANYCUSTOMERS , WNDS,WNPS ); in your package spec the WNDS tells oracle that the function will not write to the database. The WNPS tells oracle that the function will not change values in your procedure. There are other options you may add. WNDS is the only required option. There are several other postings about this around Deja if you want more details.

In article <378A1818.87ADE733_at_bayer.co.uk>,   Chris Edge <chris.edge.ce1_at_bayer.co.uk> wrote:
>
> --------------780685DAA8CB9B58C37D5A16
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hi guys,
>
> I've been struggling with using cursors inside functions with the
> DBMS_SQL command. So have looked thru the newsgroups and found the
topic
> under discussion here.
>
> I've tried your sql (with a slight correction to make it compile) and
> still get the same error in SQL*PLUS which is...
>
> ERROR at line 1:
> ORA-06571: Function HOWMANYCUSTOMERS does not guarantee not to update
> database
>
> > (BankName IN VARCHAR2, SURNAME IN VARCHAR2) RETURN NUMBER IS
> > v_query varchar2(50);
> > c_cursor integer;
> > v_count integer;
> > chris1 integer;
> > BEGIN
> > v_query := 'select count(*) from ' || BankName ||
> > 'where CustomerSurname = :surname';
> > c_cursor := dbms_sql.open_cursor;
> > dbms_sql.parse(c_cursor, v_query, dbms_sql.v7);
> > dbms_sql.bind_variable(c_cursor, ':surname',Surname);
> > dbms_sql.define_column(c_cursor,1,v_count);
> > chris1 := dbms_sql.execute(c_cursor);
> > chris1 := dbms_sql.fetch_rows(c_cursor);
> > dbms_sql.column_value(c_cursor,1,v_count);
> > return v_count;
> > END;
> >
>
> Nick Bull wrote:
>
> > Cool,
> >
> > Cheers guys.
> >
> > I'll give them a try.
> >
> > Thanks,
> >
> > nick.
>
> --------------780685DAA8CB9B58C37D5A16
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>
> Hi guys,
> <p>I've been struggling with using cursors inside functions with the
DBMS_SQL
> command. So have looked thru the newsgroups and found the topic under
discussion
> here.
> <p>I've tried your sql (with a slight correction to make it compile)
and
> still get the same error in SQL*PLUS which is...
> <p>ERROR at line 1:
> <br>ORA-06571: Function HOWMANYCUSTOMERS does not guarantee not to
update
> database
> <br>&nbsp;
> <blockquote TYPE=CITE>
> <pre>(BankName IN VARCHAR2, SURNAME IN VARCHAR2) RETURN NUMBER IS
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
v_query&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; varchar2(50);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
c_cursor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
v_count&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer;
> &nbsp; chris1 integer;
> BEGIN
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_query := 'select count
(*) from ' || BankName ||
>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 'where CustomerSurname = :surname';

> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c_cursor :=
dbms_sql.open_cursor;
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_sql.parse(c_cursor,
v_query, dbms_sql.v7);
> &nbsp;&nbsp;&nbsp;&nbsp; dbms_sql.bind_variable(c_cursor,
':surname',Surname);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_sql.define_column
(c_cursor,1,v_count);
> chris1 :=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_sql.execute
(c_cursor);
> &nbsp;chris1 :=&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dbms_sql.fetch_rows(c_cursor);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dbms_sql.column_value
(c_cursor,1,v_count);
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return v_count;
> END;</pre>
> </blockquote>
>
> <br>&nbsp;
> <br>&nbsp;
> <p>Nick Bull wrote:
> <blockquote TYPE=CITE>Cool,
> <p>Cheers guys.
> <p>I'll give them a try.
> <p>Thanks,
> <p>nick.</blockquote>
> </html>
>
> --------------780685DAA8CB9B58C37D5A16--
>
>

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Tue Jul 13 1999 - 21:30:11 CDT

Original text of this message

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