Is there a way to return a result set from an Oracle 8.1.7 procedure that would be selectable? Or to state it another way, is there any functionality in Oracle 8.1.7 that has the same functionality of SQL Server in how one can easily select from stored procedures.
Yes, Oracle does allow this, but it is done differently. Since you are already familiar with SQL Server, then I'm sure you have already seen how things are done differently in the two systems. To do this in Oracle, you have to use a REF cursor. This lets you pass a result set back and forth between procedures, functions, etc.
First, you'll need to create an object type for your cursor:
create or replace package types as type rc is ref cursor; end; /Then, you can use this object type to return values, say from a function:
create or replace function get_cursor_func return types.rc as l_cursor types.rc; begin open l_cursor for select * from dual; return l_cursor; end; /I strongly suggest that you read the documentation for more information on REF cursors. I just don't have the space to enumerate all the possibilities!!
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.