Unix Technical Forum

beginner: packaging queries?

This is a discussion on beginner: packaging queries? within the Oracle Database forums, part of the Database Server Software category; --> are procedures and functions the only types of queries that I can put into a package? I have painstakingly ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 05:05 AM
matt
 
Posts: n/a
Default beginner: packaging queries?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 05:05 AM
sybrandb
 
Posts: n/a
Default Re: beginner: packaging queries?

On Apr 10, 8:46 am, "matt" <reflectio...@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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:16 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com