Use an ampersand
(&) to identify each variable in your SQL statement. You do not need to
define the value of each variable.
The
examples below create an iSQL*Plus substitution variable for an employee
number. When the statement is executed, iSQL*Plus prompts the user for an
employee number and then displays the
EMPNO, ENAME, SAL and DEPTNO for that employee.
With the single ampersand, the user is prompted every time the command is
executed. See examples:
SQL>
select empno,ename,sal,deptno from emp where empno=&emp_no;
Enter value for emp_no: 1234
old 2: from emp where empno=&emp_no
new 2: from emp where empno=1234
no rows
selected
select
empno,ename,sal,deptno from emp where empno=&emp_no;
Enter value
for emp_no: 7369
old 2: from emp where empno=&emp_no
new 2: from emp where empno=7369
EMPNO ENAME SAL DEPTNO
---------
---------- --------- ---------
7369 SMITH 800 20
No comments:
Post a Comment