SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE ModeInOut (p_InOut IN OUT NUMBER) IS
2
3 v_LocalVariable NUMBER := 0;
4 BEGIN
5 IF (p_InOut IS NULL) THEN
6 DBMS_OUTPUT.PUT_LINE('p_InOut is NULL');
7 ELSE
8 DBMS_OUTPUT.PUT_LINE('p_InOut = ' || p_InOut);
9 END IF;
10
11 v_LocalVariable := p_InOut;
12
13 p_InOut := 8;
14
15 DBMS_OUTPUT.PUT('At end of ModeInOut: ');
16 IF (p_InOut IS NULL) THEN
17 DBMS_OUTPUT.PUT_LINE('p_InOut is NULL');
18 ELSE
19 DBMS_OUTPUT.PUT_LINE('p_InOut = ' || p_InOut);
20 END IF;
21 END ModeInOut;
22 /
Procedure created.
SQL>
SQL>
SQL>
SQL> show errors
No errors.
SQL>
SQL>
SQL> DECLARE
2 v_InOut NUMBER := 1;
3 BEGIN
4 -- Call ModeInOut with a variable, which should be modified.
5 DBMS_OUTPUT.PUT_LINE('Before calling ModeInOut, v_InOut = ' ||v_InOut);
6 ModeInOut(v_InOut);
7 DBMS_OUTPUT.PUT_LINE('After calling ModeInOut, v_InOut = ' || v_InOut);
8 END;
9 /
Before calling ModeInOut, v_InOut = 1
p_InOut = 1
At end of ModeInOut: p_InOut = 8
After calling ModeInOut, v_InOut = 8
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
SQL> BEGIN
2 ModeOut(3);
3 END;
4 /
ModeOut(3);
*
ERROR at line 2:
ORA-06550: line 2, column 12:
PLS-00363: expression '3' cannot be used as an assignment target
ORA-06550: line 2, column 4:
PL/SQL: Statement ignored
SQL>
SQL>
SQL>
SQL> BEGIN
2 ModeIn(3);
3 END;
4 /
Inside ModeIn: p_In = 3
p_In = 3
PL/SQL procedure successfully completed.
SQL>
SQL>
|