Example of using Bind Variables in SQLPLUS Oracle

Create the Bind Variables:

SQLPLUS sys as sysdba
SQL> variable var number

Assign the value to Bind Variable:

SQL> begin
  2  :var := 100;
  3  end;
  4  /

Show Bind Variable value:

SQL> print var
var
------
100

use of bind variable in sql query:

SQL> select employee_id,first_name from hr.employees where department_id = :var;

EMPLOYEE_ID FIRST_NAME
----------- -------------------
        108 Nancy
        109 Daniel
        110 John
        111 Ismael
        112 Jose Manuel
        113 Luis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.