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
This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply