Solved

Stored procedure with one output parm and a result-set

Posted on 2014-10-15
2
323 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:Dave Ford
[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:Dave Ford
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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

729 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