It says while using OUT parameter, Formal parameter cannot be used in an expression..we know that IN parameter cannot be used as assignment target, but can be used to assign a value, here what is mentioned about OUT parameter is that it cannot be used to assign a value, but please see this code , here y variable is assigned a value using x formal parameter....
CREATE OR REPLACE procedure proccer1 (n in varchar2, p in number, x out number)
cursor firstcur is
select * from temp;
insert into temp values (n, p);
fetch firstcur into cur_val;
exit when firstcur%NOTFOUND;
insert into t values (cur_val.point);
X := N + 10;
dbms_output.put_line ('the output value : ' || x);
Y := x + 10;
dbms_output.put_line ('now new output value : ' || Y);
so what is it which is mentioned on that oracle docs page whose link i have given above..?
What they are talking about is the following. If your OUT parameter is X then
X := 3;
Y := X + 3;
Is not legal. You can assign a value to an out parameter, but you can't use it to the right of the equal sign.
Hi Beilstwh, thanks for replying! here, i also understood the same.. but have a look at the code i mentioned above, 'y' variable is outputted there after adding 10 to 'x' formal parameter....so it means once we assign a value to formal parameter,after that it can be used in an expression? thanks again
OK, so here's a small test case. I removed cursors and other unnecessary stuff (besides, procedure you posted is kind of strange - why do you add CHAR (N) to a number (10)?
SQL> create or replace procedure prc_1 (n in number, x out number) as
2 y number;
4 x := n + 10;
5 dbms_output.put_line ('the output value : ' || x);
7 Y := x + 10;
8 dbms_output.put_line ('now new output value : ' || Y);
2 l_out number;
4 prc_1 (100, l_out);
5 dbms_output.put_line('Value returned from a procedure : ' || l_out);
the output value : 110
now new output value : 120
Value returned from a procedure : 110
PL/SQL procedure successfully completed.
Hi Littlefoot, thanks for replying and explaining..yes everything is okay in that code & the code which i wrote is also executing fine. I was just confused about what is mentioned in the link i gave in my question..in that link if you see table 7-2, there it's mentioned that 'Formal parameter cannot be used in an expression'.... As to what is mentioned in that table about 'IN' parameter & 'OUT' parameter, this above line('formal parameter.....) got me confused that an 'OUT' parameter would not be used to assign a value, but now am confirmed that it can be used to assign a value as well as can be assigned a value..okay dont wanna confuse anybody else ..... so anyways thanks for the help !!