Adding parameters to SQL query


SQL> edit mynameis
/*
File           :mynameis.sql
Purpose        : Display information from the emp table in the following format:
               "My name is INITCAP(ename), I started work on hiredate."
Params         : &dept (integer) - Department number
*/
select
   (
   'my name is ' || INITCAP(ename) ||
   ', I started work on ' || hiredate
   )
   as "Below is a list of Employees"
from
   emp
where
   deptno = &dept
/
Â

SQL> start mynameis
DOC>File           :mynameis.sql
DOC>Purpose        : Display information from the emp table in the following format:
DOC>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "My name is INITCAP(ename), I started work on hiredate."
DOC>Params         : &dept (integer) - Department number
DOC>*/
Enter value for dept:
THE PROGRAM ASKING FOR VALUE:
ENTER NUMBER 30:
Enter value for dept: 30
old 10:       deptno = &dept
new 10:       deptno = 30
Below is a list of Employees
--------------------------------------------------
my name is Allen, I started work on 20-FEB-81
my name is Ward, I started work on 22-FEB-81
my name is Martin, I started work on 28-SEP-81
my name is Blake, I started work on 01-MAY-81
my name is Turner, I started work on 08-SEP-81
my name is James, I started work on 03-DEC-81
SQL>Â
NOTE ONLY:Â
 ---------------------------
 SQL> select deptno from emp;
Tue Dec 19                                                            page   1
                                    REPORT
   DEPTNO
----------
       20
       30
       30
       20
       30
       30
       10
       20
       10
       30
       20
       30
       20
       10
                               Report Completed
SQL>
-------------------------------------
- sql_command's blog
- Login or register to post comments
- 351 reads
- Email this page












