Solved

Stored procedure with one output parm and a result-set

Posted on 2014-10-15
2
321 Views
Last Modified: 2014-10-15
Greetings, experts!

I apologize for so many "rookie questions”. I’m finding it challenging to transfer my DB2 experience into Oracle, but I'm getting closer.

I wrote a stored procedure in Oracle 11g that returns two output parameters, and that works beautifully.

var theId number;
var theDesc varchar2;
exec MySchema.GetNextVersion (:theId, :theDesc);
begin
  dbms_output.put_line(theId = ' || :theId);
  dbms_output.put_line('thedesc = ' || :theDesc);
end;

Open in new window


output:

theId = 8
theDesc = V15

Unfortunately, the client developer is having a problem dealing with the varchar2 output parameter, so he asked that I change that second parameter into a one-record result-set. I successfully changed the stored proc, but I’m having a hard time testing it.

The new stored proc header looks like this:

CREATE OR REPLACE PROCEDURE MySchema.GetNextVersionWithResultset (
   pVersionId   OUT NUMBER,
   mycursor     OUT SYS_REFCURSOR)
IS
...

Open in new window


When I try to call the new proc, I get an error:

var theId number;
DECLARE  MYCURSOR SYS_REFCURSOR; 
exec MySchema.GetNextVersionWithResultset (:theId, :MYCURSOR);

Open in new window


output:

ORA-06550: line 2, column 66:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   begin function pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor delete
   exists prior

I realize this is probably mind-numbingly easy, but what am I doing wrong?

Thanks!
DaveSlash
0
Comment
Question by:daveslash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40382706
Using sqlplus try this:
var theId number;
var MYCURSOR REFCURSOR;
exec MySchema.GetNextVersionWithResultset (:theId, :MYCURSOR);
print mycursor

declare is a pl/sql block designation.  you need a complete block if you go down that path.
0
 
LVL 18

Author Closing Comment

by:daveslash
ID: 40382730
You nailed it, slightwv.

That worked perfectly.

Thanks!
DaveSlash
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question