DB2 Server for VSE & VM: Interactive SQL Guide and Reference


Appendix A. Answers to the Exercises

The following answers are shown with each clause on a separate line so that you can easily check your commands. You can, of course, put the entire command on one line if it fits. Or, you can use several lines and break each line at a different place than shown here. It is your choice. Just follow the rules for using the continuation character.

Exercise 1:

(page ***)

1.   forward 39
2.   forward max
3.   right 1     or    column 2
4.   left 1      or    column 1
5.   backward max
6.   print
7.   end

Exercise 2:

(page ***)

1.   hold select * from department
2.   change /*/&1,&2/;
3.   a.   start (deptno deptname)
     b.   end
4.   change /nt/nt where &3/;
5.   start (deptname mgrno admrdept='e01')

Exercise 3:

(page ***)

1.   select empno,projno,emptime -
     from emp_act -
     where projno='if1000' or projno='if2000' -
     order by projno,empno

2.   format separator '  *  '

3.   format exclude empno
         OR
     format exclude 1
         OR
     format include only (projno emptime)
         OR
     format include only (2 3)

4.  a.  format column emptime name proptn
            OR
        format column 3 name proptn
 
    b.  format column proptn width 8
            OR
        format column 3 width 8
Note:You can also do items 2 through 4 using a single FORMAT command:
        format separator ' * ' exclude 1 -
        column emptime name proptn width 8

Exercise 4:

(page ***)
DB2 Server for VSE

1.   set copies 2

2.   list set *

3.   select * -
     from proj_act -
     where projno='ad3112' -
     order by acendate

4.   format group acendate
         AND
     format exclude (acstdate)
         OR
     format group acendate exclude (4)

5.   format ttitle 'personnel programming deadlines'

6.   print
DB2 Server for VM

1.   list set *

2.   select * -
     from proj_act -
     where projno='ad3112' -
     order by acendate

3.   format group acendate
         AND
     format exclude (acstdate)
         OR
     format group acendate exclude (4)

4.   format ttitle 'personnel programming deadlines'

5.   print copies 2

Exercise 5:

(page ***)

1.   recall myquery
2.   change /&1/salary between 25000 and 30000 order by 2/
3.   start
4.   format exclude (3)
         OR
     format exclude (midinit)
5.   format separator ' |*| '
6.   format column edlevel name 'school years'
7.   a.  end
     b.  store EXER11
8.   list sql *
9.   help store

Exercise 6:

(page ***)

This answer assumes you have a REMARKS column in your ROUTINE table.

1.   input routine
     a.  'exer13',10,'select actno,actdesc -',null
         'exer13',20,'from activity',null
     b.  'exer13',30,'format separator 3 blanks',null
     c.  'exer13',40,'display',null
     d.  'exer13',50,'print copies 3',null
     e.  'exer13',60,'end',null
     end
Note:Any sequence numbers are valid as long as they are in ascending order.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]