Simple procedure [message #642851] |
Mon, 21 September 2015 13:34 |
|
jclouser
Messages: 2 Registered: September 2015 Location: Tampa
|
Junior Member |
|
|
Compiles without errors.
CREATE OR REPLACE PROCEDURE VBS
(inusername in dba_users.username%TYPE,
outusername out dba_users.username%TYPE )
is
begin
select username
into outusername
from dba_users
where username = inusername;
END VBS;
/
But when I:
EXECUTE VBS ARUNION
Get:
ERROR at line 1:
ORA-06550: line 1, column 11:
PLS-00103: Encountered the symbol "ARUNION" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "ARUNION" to continue.
New to this, please help.
|
|
|
|
|
|
|
Re: Simple procedure [message #642856 is a reply to message #642853] |
Mon, 21 September 2015 15:02 |
|
Littlefoot
Messages: 21808 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Well, the only thing you can omit is the DBMS_OUTPUT.PUT_LINE call (it just displays the result).
As the procedure you created has two parameters - one IN and one OUT, you have to pass them when you call the procedure. (Ooops! I just noticed that I missed the OUT parameter - I'll fix it now!) In order to be able to accept the result, you have to declare a variable which will do that job - it is the L_OUT in my example.
Being a PL/SQL piece of code, you need to use all parts that its syntax requires: declaration section along with executable code embedded into BEGIN-END keywords.
So, there's nothing smaller in this case.
However: perhaps you should have used a function (instead of a procedure) as it returns a value anyway.
Finally, consider visiting this page: Oracle 10g documentation. You didn't mention which version you use. 12c is the latest one, and 10g is now obsolete but the documentation page is neatly arranged so that newbies - like you - can easily spot what's interesting. Start with "Getting started", and then move to PL/SQL in "PL/SQL User's Guide and Reference" and "Application Developer's Guide - Fundamentals".
If you feel that 10g doesn't suit your needs, feel free to read documentation related to version you use. It can be found on the Oracle Technology Network.
|
|
|