5th Example - Bind Variable on PL/SQL
Bind variable is a variable that receives input from outside the PL/SQL block. Difference between
bind variables and
substitution variables are bind variables declared outside the PL/SQL
block and bind variables
have symbol ":"
in the beginning of the variable name. Here is an example of PL/SQL block that has a bind variable:
VARIABLE n1
NUMBER;
VARIABLE n2
NUMBER;
DECLARE
Hasil
NUMBER;
BEGIN
:n1
:= 12;
:n2
:= 17;
Hasil
:= :n1 + :n2;
DBMS_OUTPUT.PUT_LINE
(Hasil);
END;
/
Seen from the above examples
that there are 2
bind variables n1
and n2. Both
variables are declared before the
DECLARE section. On
the use of the content in the program, n1 will be used as :n1 and n2
will be used as :n2.
Leave a Comment