actually, i take that back.. your syntax should be correct if you just execute as script from within toad.
good luck,
daniels
Main Topics
Browse All TopicsI'm using TOAD for Oracle. I'm trying to execute a stored procedure with two parameters - one IN and one OUT. It looks like this:
PROCEDURE get_stuff (
parm_1 IN VARCHAR2,
parm_2 OUT currefcursor)
In the SQL Editor window in TOAD, I've tried various things to no avail. I'm sure this is something simple that I'm missing, 'cause I've tried all sorts of things I've seen in other solutions here at Experts Exchange, but can't get past various errors. Here's what I think should work from what I've seen here:
var p1 VARCHAR2 := 'some text';
var p2 currefcursor;
EXEC get_stuff( :p1, :p2 );
When I run this, though, the SQL Editor pops up a window titled 'Variables' that appears to be looking for a value. No matter whether I put something in the 'Value' textbox or not, when I click OK, it says:
ORA-00900: invalid SQL statement
and highlights the 'var' in front of p1.
Please tell me what I'm missing!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
well,
I think you are executing a procedure that is defined in a package. And "currefcursor" is a type defined in the package. You cannot invoke the procedure from the sql editor the way you are trying here.
the call should be like
declare
p1 VARCHAR2 := 'some text';
p2 <package_name>.currefcurso
begin
<package_name>.get_stuff(p
end;
/
For dan, running your suggestion as a script gives me this:
Bind variable "p1" not declared.
Bind variable "p2" not declared.
ORA-01008: not all variables bound
For MohanKNair, running your suggestion as a script gives me this:
Bind variable "p2" not declared.
PL/SQL procedure successfully completed.
ORA-01008: not all variables bound
For sujith80, running your suggestion as a script gives me this:
ORA-06550: line 2, column 4:
PLS-00215: String length constraints must be in range (1 .. 32767)
ORA-06550: line 3, column 4:
PLS-00201: identifier 'PKG_SOME_PKG.CURREFCURSOR
ORA-06550: line 3, column 4:
PL/SQL: Item ignored
ORA-06550: line 5, column 38:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
You're right that I'm using a package. So my code looked like this when I ran your suggestion:
declare
p1 VARCHAR2 := 'some text';
p2 PKG_SOME_PKG.currefcursor;
begin
PKG_SOME_PKG.get_stuff(p1,
end;
I tried adding a length to VARCHAR2 like VARCHAR2(200), which fixed the length constraints part of the error, so it became this:
ORA-06550: line 3, column 4:
PLS-00201: identifier 'PKG_SOME_PKG.CURREFCURSOR
ORA-06550: line 3, column 4:
PL/SQL: Item ignored
ORA-06550: line 5, column 38:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 5, column 3:
PL/SQL: Statement ignored
For all: I may or may not try more over the weekend, so please be patient if I don't get back with you for a couple of days. Please do continue to assist, though - I appreciate your help!
Here:
declare
p1 VARCHAR2 := 'some text';
p2 PKG_SOME_PKG.currefcursor;
begin
PKG_SOME_PKG.get_stuff(p1,
end;
You should know where "currefcursor" is defined. It is not a standard declaration. It must be defined in one of your packages.
Otherwise if you just want to test your code you can change the above declaraion as :
declare
p1 VARCHAR2(200) := 'some text';
p2 sys_refcursor;
begin
PKG_SOME_PKG.get_stuff(p1,
end;
Here's a summary of the procedure code within the package:
PROCEDURE get_stuff (
p1_parm IN VARCHAR2,
p2_parm OUT currefcursor) IS
BEGIN
OPEN p2_parm FOR
SELECT ...
.
. (uses p1_parm for a value in the WHERE clause)
.
END get_stuff;
I didn't write the procedure - it's been around awhile, being used by some applications. It seems to work fine for the applications. I want to see the data that should be returned by the procedure, so I can understand its relationship to the applications that use it. There is a view in the FROM that I don't have access to, but I would expect a different error message if it was failing because of that. From the messages I'm getting, Toad (or Oracle, actually) seems just to dislike my syntax. Aargh!
'currefcursor' is used in many of the procedures included in this package. I don't see it defined anywhere, though.
And, sujith80, I tried both of your suggestions earlier in this thread - see my response from 10/14, 4:46pm, above, for the results...
Thanks!
I didn't think so - I'm taking over support of this package since the person who wrote it has left the company. I'm using a team id to try to access it. However, the procedure I'm trying to run references a view that I don't have access to. I thought if I ran the procedure from the package via TOAD, it would have access and be able to return data. I guess not.
I'm thinking the applications that use it probably utilize a special user id that gives them rights to run the procedures in the package. I'm new to stored procedures, obviously. From my programming background, I know this kind of thing is done on servers for applications, but I didn't know it could be done for databases (and, I'm assuming this is the case). Does that make sense?
You're right, sujith80, that your suggestion helped me to figure out what was happening. I wanted to split the points, though, and I could only choose one "accepted answer". With my comment just above your "assisted answer", I had by then pretty much figured out that it was a security issue. Both your and dan's answers pretty much confirmed my suspicions. Your response gave me another step to try (running the 'desc' commands), but didn't explain what the purpose of the step was. Dan's answer made the results a little clearer. If I were an Experts-Exchange user looking for a solution to a similar problem, I'd be scrolling down looking for those 'assisted' and 'accepted' answers. So, yours gives the user the heads up that the 'desc' commands might give them a clue, while dan's answer pretty much sums up what my results from those commands showed.
I appreciate the assistance from everyone who responded, and everybody gave me some clues - and I learned from you all while you were responding. I do, at the least, offer you my sincerest thanks for taking the time to work on my question.
Business Accounts
Answer for Membership
by: drs66Posted on 2006-10-12 at 16:31:30ID: 17720294
try this, sqlplus will behave different than toad.
declare
p1 VARCHAR2 := 'some text';
p2 currefcursor;
begin
get_stuff(p1, p2);
end;
/
execute as script in toad.
good luck,
daniels