oracle stored procedure - printing varchar2 output variable
I execute a stored proc as follows:
var myOutput varchar2
exec myproc(:myOutput)
print myOutput
However, this does not work.
I get an error message saying:
Bind Variab开发者_开发知识库le "myOutput" is NOT DECLARED
When I use a refcurser rather than a varchar2 in other procs, this works. What am I doing wrong?
Thanks!
So you have a procedure like this:
CREATE OR REPLACE PROCEDURE bark ( woof IN OUT VARCHAR2 )
IS
BEGIN
woof := 'Woof!';
END bark;
Then you run:
SQL> var myOutput VARCHAR2(10)
SQL> exec bark(:myOutput);
PL/SQL procedure successfully completed.
SQL> print myOutput
MYOUTPUT
--------------------------------
Woof!
Is this similiar to what you are trying to do?
Is that exactly what you're running? If so, I think the problem is you're not specifying the size of your myOutput
variable. You need to do this (adjusting the length as appropriate to your needs):
SQL> var myOutput varchar2(40)
It's in the documentation.
精彩评论