Q
Problem solve Get help with specific problems with your technologies, process and projects.

Selecting from the results of a stored procedure in 8.1.7

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


This was last published in July 2002

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.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close