![]() |
||
|
Software tools | Programming tips | Database fundamentals Using a ref cursor in Oracle PL/SQL
The following example shows how you can define a global ref cursour in your Package Specification,
and how it is transformed to a local cursor for any given function in the Package Body:
-- ***********************************************************************
TYPE csGetResultSet is REF CURSOR;
-- ***********************************************************************
function sfGetAccountInterval
CREATE OR REPLACE package body GetRefCursors is
-- ***********************************************************************
function sfGetAccountInterval
open csGetAccounts for
SELECT accounts.account_no,accounts.name
return csGetAccounts;
end sfGetAccountInterval;
end GetRefCursors; This can be used as a template to build a framework for handling all SELECT access to your tables through such a mechanism. This way you will deliver a generic and consistent interface for all applications and/or modules that need to access data within your different tables. Not to mention: The DBA can easily tune the various SELECT statements without even touching the application(s), no matter how many different modules that are accessing a given table. Time saved, and secure, identical and (hopefully) error-free code is delivered to anyone from just one place. If you need to learn how you can use a ref cursor in Oracle using Java, read here: Oracle ref cursor in Java Other important resources on this site:
Oracle DBA
Return from Ref cursor to Programming
|
![]() Database Design FORUM
What visitors say...
"I just stumbled across your site looking for some normalization theory and I have to say it is fantastic.
Read more
Testimonials
I have been in the database field for 10+ years and I have never before come across such a useful site. Thank you for taking the time to put this site together." Mike, USA Free eBookSubscribe to my newsletter and get my ebook on Entity Relationship Modeling Principles as a free gift:![]() WorkshopOn rare occasions, I may perform a Database Design Workshop . Unfortunately, I am currently unable to, but maybe later...Influence meInfluence the content on this site: I want to know what database information you need the most: Participate in my Database Design Content investigation. I would appreciate it if you took the time... |
|
|
Theory & Practice
Worst DB Designs Database eBooks DB Normalization Analysis Phase Database Keys Software Tools DB Glossary Appl.Architecture Oracle DBA MySQL DBA SQL Server DBA Install Oracle Install SQL Server Proj.Management Oracle Constraint Programming Tips Bookstore Internet biz. Database Normalization eBook:![]() |
||
|
Copyright © 2004-2008 www.databasedesign-resource.com / Alf A. Pedersen
All rights reserved. All information contained on this website is for informational purposes only. *Disclaimer: www.databasedesign-resource.com does not warrant any company, product, service or any content contained herein. Return to top
The name Oracle is a trademark of Oracle Corporation.
|
||