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: beginner: packaging queries?

Re: beginner: packaging queries?

From: sybrandb <sybrandb_at_gmail.com>
Date: 10 Apr 2007 02:10:08 -0700
Message-ID: <1176196207.992818.120330@w1g2000hsg.googlegroups.com>


On Apr 10, 8:46 am, "matt" <reflectio..._at_gmail.com> wrote:
> are procedures and functions the only types of queries that I can put
> into a package?
>
> I have painstakingly created a couple of plsql db queries and saved
> them as *.sql files. Is there a simple way to create a package out
> of these two plsql queries or do I need to re-write them as stored
> procedures/functions? I'm dreading having to translate these into
> sprocs/functions because they contain cursors that i don't yet know
> how to implement.
>
> Thanks.

Procedures and functions are *NOT* queries. They are procedural constructs.
They can return a REF CURSOR, but this is more or less a kludge needed by Mickeysoft products.
Queries can be packaged when you make sure you convert the statement to a cursor in the package *specification*. Associate a TYPE definition to it.
Like this
package mypack is
cursor mycur is
select * from emp;

end;

outside the package you would
define a variable of mypack.mycur%rowtype; open mycur;
fetch mycur into myvar;

etc.

Hth

--
Sybrand Bakker
Senior Oracle DBA
Received on Tue Apr 10 2007 - 04:10:08 CDT

Original text of this message

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