• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2196
  • Last Modified:

Oracle stored procedure with Sys_refcursor output, Lightswitch, Devart Entity Framework, Toad

I am calling an insert procedure through Microsoft Lightswitch app, and I get this error:

ORA-06550: line 29, column 8:
PLS-00103: Encountered the symbol "SP_MUSIC_INS" when expecting the following:

The procedure is an oracle procedure returning a sys_refcursor.  It has been mapped through DEVART entity framework 4 to work with Lightswitch app as a RIA service.

To test the oracle procedure works, I am trying to run it from oracle.  When I walk through Debug everything is good and the refcursor parameter indicates 1iteration. (Can't see vaule due to it being a refcursor.)

What did I do wrong?   How do I get it to run correctly in Toad?  How do you test a sys_refcursor in SQLPLUS?  Did I miss something in a refcursor setup step in TOAD and in Entity Framework causing this error?

Here is the script I am executing in Toad for the refcursor but I get an the error an not the ability to define the ref_CURSOR AS A CURSOR.
p_Music_GENRE_DESC                  Music.GENRE_DESC%TYPE;
p_SERIES_IND                        Music.SERIES_IND%TYPE;
p_Music_GENRE_CODE_RC                sys_refcursor;

  p_Music_GENRE_DESC := 'Test\Proc Test';
  p_SERIES_IND := 'N';
--  p_Music_GENRE_CODE_RC := null;


Here is how I am calling and assigning the sys_refcursor output.
     RETURNING Music_CODE into p_Music_GENRE_SEQ;

open p_Music_GENRE_CODE_RC for select p_Music_GENRE_SEQ as p_Music_GENRE_SEQ from dual;

Thank you,

1 Solution
johnsoneSenior Oracle DBACommented:
Not sure I can help with your other issues, but your question of how do I see the information in a ref cursor in SQL*Plus, I think I can help you with.

This way should work with the way you have your code written.  There are other easier ways if you are using a function that returns a sys_refcursor, rather than having it be an out parameter.

var v_rc sys_refcursor
exec sp_music_ins('Test\Proc Test','N',v_rc);
print v_rc;

Open in new window

slightwv (䄆 Netminder) Commented:
>>PLS-00103: Encountered the symbol "SP_MUSIC_INS" when expecting the following:

The reason for this error is the EXEC inside a pl/sql block.  The EXEC is a sqlplus command not a pl/sql command.

As soon as the issue the begin...end; you are inside pl/sql.  Just remove the EXEC.
Mark GeerlingsDatabase AdministratorCommented:
I agree that the word "exec" in a PL\SQL procedure is not needed or allowed there.  I also wonder about the "commit;" on the next line.  That will not cause an error, but is it needed?  It will add at least a small performance impact, and it could cause unexpected problems if the application has made any changes prior to this call and if the user does not expect those changes to be committed automatically, or if the user (or the application) assumes that earlier changes could still be rolled back.

On the concept of using "ref-cursors": this is one of the fundamental design differences between Oracle and SQL Server.  In SQL Server (and in Microsoft tools) it is expected that a database stored procedure will handle the database cursor and will return a record set to the application.  Historically in Oracle, it was assumed that the application would submit SQL queries directly and that the application would manage the resulting record set  (without depending on a database stored procedure for this functionality).  Oracle has added support for "ref cursors" in PL\SQL (probably because programmers familiar with Microsoft tools asked for that functionality) but that doesn't mean that "ref cursors" are easy to work with in the various Oracle tools.
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

DavidSenior Oracle Database AdministratorCommented:
One side comment, there MAY be a known bug for refcursors in Toad, using Windows 64 bit OS.  Check with Toad tech support if that's your scenario.
wpeterbAuthor Commented:
Thank you.  I removed the Execute immediate from within procedure.
wpeterbAuthor Commented:
Quick response and the answer solved the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now