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: functions, pragmas, and a mystery...

Re: functions, pragmas, and a mystery...

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Fri, 5 Nov 1999 11:02:10 +0100
Message-ID: <7vua1n$35u$1@oceanite.cybercable.fr>


There is 2 points:
First, you missed a / between the "end" of the "create package" block and the "create package body" one. Second, you can't use the pragma restricted_references(foo, wrds) because you use the package dbms_sql that does not garanties not writing in the DB.

--
Have a nice day
Michel

David Fetter <dfetter_at_shell4.ba.best.com> a écrit dans le message : 3822a809$0$210_at_nntp1.ba.best.com...
> Kind people,
>
> I'm trying to create a function that will count rows (for reporting
> porpoises :)
>
> So I whipped out a tall stack of Oracle books, and have written the
> following package, which contains just that function. A error message
> ensues, and I just don't know what I'm doing wrong here.
>
> What am I missing?
>
> Thanks in advance for any tips, hints, or thoughts on the subject.
>
> Cheers,
> David.
>
> 1 CREATE OR REPLACE PACKAGE analyse_this AS
> 2 FUNCTION foo(table_name_in VARCHAR2)
> 3 RETURN NUMBER;
> 4 PRAGMA RESTRICT_REFERENCES(foo, WNDS);
> 5 END analyse_this;
> 6
> 7 CREATE OR REPLACE PACKAGE BODY analyse_this AS
> 8 FUNCTION foo(table_name_in VARCHAR2)
> 9 RETURN NUMBER IS
> 10 v_cursor NUMBER;
> 11 v_getcount VARCHAR2(255);
> 12 v_numrows NUMBER;
> 13 BEGIN
> 14 v_cursor := DBMS_SQL.OPEN_CURSOR;
> 15 v_getcount := 'SELECT COUNT(*) FROM ' || table_name_in;
> 16 BEGIN
> 17 DBMS_SQL.PARSE(v_cursor,v_getcount,DBMS_SQL.V7);
> 18 v_numrows := DBMS_SQL.EXECUTE(v_cursor);
> 19 END;
> 20 RETURN v_numrows;
> 21 END foo;
> 22* END analyse_this;
> SQL> show errors
> Errors for PACKAGE ANALYSE_THIS:
>
> LINE/COL ERROR
> --------
> -----------------------------------------------------------------
> 7/1 PLS-00103: Encountered the symbol "CREATE"
>
>
> --
> David Fetter 888 O'Farrell Street Apt E1205
> david_at_fetter.org San Francisco, CA 94109-9046
> http://fetter.org/~shackle phone: +1 415 567 2690 fax: +1 415 567 2340
>
> I don't do drugs anymore 'cause I find I get the same effect just by
> standing up really fast.
> Johnathan Katz
Received on Fri Nov 05 1999 - 04:02:10 CST

Original text of this message

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