Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Oracle/OAS
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Oracle/OAS
How to return a collection of records from a stored procedure?
Nilesh Raje
Ranch Hand
Posts: 153
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How to return a collection of records from a stored procedure.Can anyone give me some example code?
Gene Hilpert
Ranch Hand
Posts: 51
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here is one way.
CREATE OR REPLACE PACKAGE myschema.my_pk AS TYPE out_cursor IS REF CURSOR; -- depending on you application calling the procedure you may not need the RECORD and TYPE statements TYPE my_typerec IS RECORD ( field1 VARCHAR2 (10) ,field2 VARCHAR2 (10) ,field3 VARCHAR2 (10) ,field4 VARCHAR2 (10) ,field5 VARCHAR2 (10) ); TYPE my_typecur IS REF CURSOR RETURN myschema.my_pk.my_typerec; PROCEDURE my_procedure (parm1 IN VARCHAR2 ,parm2 IN VARCHAR2 ,outcursor OUT myschema.my_pk.my_typecur -- if you dont need the RECORD or TYPE then this is just out_cursor ); END my_pk; CREATE OR REPLACE PACKAGE BODY myschema.my_pk AS PROCEDURE my_procedure (parm1 IN VARCHAR2 ,parm2 IN VARCHAR2 ,outcursor OUT myschema.my_pk.my_typecur -- if you dont need the RECORD or TYPE then this is just out_cursor ) AS BEGIN OPEN outcursor FOR SELECT field1 ,field2 ,field3 ,field4 ,field5 FROM my_table; EXCEPTION WHEN NO_DATA_FOUND THEN outcursor := NULL; END; END my_pk;
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
can PL/SQL return a collection
Need for stored procedure..
Java stored procedures and collections(ORCL)
Performance problem - using Ref Cursor in stored procedure call from Hibernate
Retrieving information for a collection of objects from database
More...