Cursors Seminar

Embed Size (px)

Citation preview

  • 8/13/2019 Cursors Seminar

    1/2

    CG096 Week 4 Seminar

    Writing Cursors

    PL/SQL CURSORS

    In order to perform the following exercises you will need to create a table withcolumns as shown below:

    EMPLOYEE:Empid num erEmpname varchar !"#$

    Empgrade number Empsalary number

    Your tas% is to create a procedure which& when evo%ed& will increase the salary for anemployee by '"## or '(### depending on his or her grade !the higher the grade& thehigher the employee)s ran%ing within the company$* You will need to populate the tablefirst with a minimum of (# entries& the empgrade value of which should be between ( and"* + script file Create!Emp"s#$ is provided on ,lac%board for this purpose*

    -he code overleaf will provide a s%eleton for the procedure& but you will need to fillin the missing bits indicated by o$d letters* You are recommended to use .otepad to do

    the editing& and you will need to give your file the extension "s#$&e.g * calling itsa$ar%!in&rease"s#$ * Once you have done this& you should attempt to compile the code by means of the ' command !using the full path/name of the file$ in 01L2Plus* IfOracle tells you that the procedure has been compiled with errors& entering the commands(o) errors will list the problems with the code* Once the procedure has compiledsuccessfully& you can run it by typing e*e&ute sa$ar%!in&rease at the 01L3 prompt*

    .O-E0:4emember that you need to have a variable to store each component of the return fromthe cursor*5here an I6 statement is used& remember to E.7 I68

    -he salaries for the grades are listed overleaf:

  • 8/13/2019 Cursors Seminar

    2/2

    Grade Sa$ar% Range( (####/("###

    (9###/( "##; ( ###/ ###

    9 ("##/ ""##" "###/;#### E*er&ise +,