3rd Example - Substitution Variable (NUMBER) on PL/SQL
Substitution
variable is dynamic variable. Substitution variable
on its use in the
PL / SQL block can receive input values
from outside the PL / SQL block.
Input value can
change each time the PL / SQL block
is executed. Substitution variable
indicated by “&” at the
beginning of the variable name.
Here is an example of PL / SQL block that has
2 substitution variables:
DECLARE
Result NUMBER;
Input1 NUMBER;
Input2 NUMBER;
BEGIN
Input1 := &in1;
Input2 := &in2;
Result := Input1 + Input2;
DBMS_OUTPUT.PUT_LINE(Result);
END;
/
When executed, it will request 2 input values. For example
in1 variable filled by 10 and in2 variable filled by 20, the result will be
shown is 30.
Leave a Comment