Actual code depends on tool you use. In SQL*Plus, it is the &
; in SQL Developer or TOAD, that would be a :
. Also, GUI tools usually don’t require enclosing string parameters into single quotes.
Here’s a SQL*Plus example:
SQL> select * from emp where job = '&job' and sal <= &sal;
Enter value for job: CLERK
Enter value for sal: 1000
old 1: select * from emp where job = '&job' and sal <= &sal
new 1: select * from emp where job = 'CLERK' and sal <= 1000
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17.12.80 800 300 20
7900 JAMES CLERK 7698 03.12.81 950 30
SQL>
Or, a prettier way would be to use ACCEPT
SQL*Plus command:
SQL> accept par_job prompt 'Enter job '
Enter job CLERK
SQL> accept par_sal prompt 'Enter salary '
Enter salary 1000
SQL> select * from emp where job = '&par_job' and sal <= &par_sal;
old 1: select * from emp where job = '&par_job' and sal <= &par_sal
new 1: select * from emp where job = 'CLERK' and sal <= 1000
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17.12.80 800 300 20
7900 JAMES CLERK 7698 03.12.81 950 30
SQL>
SQL Developer would accept the same code as above, or – alternatively –
select * from emp where job = :job and sal <= :sal;
1
solved I want to search job and salary from employee table but I am getting error like invalid relational operator [closed]