Examine the following code:
What is the outcome?
A. The procedure is created successfully and displays the values 20 and 30 when it is called.
B. The procedure gives errors because the parameters should be in out mode.
C. The procedure gives errors because the host variables cannot be referenced anywhere in the definition of a PL/SQL stored procedure.
D. The procedure is created successfully but does not display any values when it is called because the host variables cannot be displayed inside the procedure.
Error after executing above code confirming that correct answer is C:
set serveroutput on
variable n1 number
variable n2 number
create or replace procedure proc1
(:n1 in out number, :n2 in out number) is
begin
:n1:=20;
dbms_output.put_line(:n1);
:n2:=30;
dbms_output.put_line(:n2);
end;
/
Warning: Procedure created with compilation errors.
HR@XE > show err;
Errors for PROCEDURE PROC1:
LINE/COL ERROR
——– —————————————————————–
2/2 PLS-00049: bad bind variable ‘N1’
2/2 PLS-00103: Encountered the symbol “” when expecting one of the
following:
current delete exists prior
The symbol ” was inserted before “” to continue.
2/21 PLS-00049: bad bind variable ‘N2’
2/21 PLS-00103: Encountered the symbol “” when expecting one of the
following:
current delete exists prior
The symbol ” was inserted before “” to continue.
4/1 PLS-00049: bad bind variable ‘N1’
5/22 PLS-00049: bad bind variable ‘N1’
6/1 PLS-00049: bad bind variable ‘N2’
7/22 PLS-00049: bad bind variable ‘N2’