More on IF statements Use speaker notes for additional information!
PL/SQL - IF BEGIN SELECT yrgoal, state INTO v_yrgoal, v_state FROM donornew WHERE idno = v_idno; IF v_state = 'MA' THEN IF v_yrgoal > 300 THEN v_newgoal := v_yrgoal * 1.3; ELSE IF v_yrgoal > 100 THEN v_newgoal := v_yrgoal * 1.2; ELSE v_newgoal := v_yrgoal * 1.1; END IF; ELSE IF v_state = 'RI' THEN IF v_yrgoal > 250 THEN v_newgoal := v_yrgoal * 1.25; ELSE v_newgoal := v_yrgoal * 1.15; END IF; ELSE v_newgoal := v_yrgoal; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; COMMIT; END; / SET VERIFY ON SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal NUMBER(7,2); v_newgoal NUMBER(7,2); v_state VARCHAR2(2); This is the code for donor2 as it appears in the editor (shown in two columns for space considerations). This code uses a complex IF structure with IF statements embedded in other IF statements. The flowchart for the logic is shown on the next slide.
PL/SQL - IF v_state = MA v_yrgoal > 300 v_newgoal := v_yrgoal * 1.3 v_yrgoal > 100 v_newgoal := v_yrgoal * 1.2 v_newgoal := v_yrgoal * 1.1 v_state = RI v_yrgoal > 300 v_newgoal := v_yrgoal * 1.25 v_newgoal := v_yrgoal * 1.15 v_newgoal := v_yrgoal YN Y Y Y Y N N N N
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa PL/SQL - IF donor2 Enter value for input_idno: PL/SQL procedure successfully completed. Input truncated to 13 characters SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa This is the segment of code that was executed to cause donor to increase from 440 to 550. IF v_state = 'RI' THEN IF v_yrgoal > 250 THEN v_newgoal := v_yrgoal * 1.25;
SET VERIFY OFF DECLARE v_pay_id first_pay_new.pay_id%TYPE :=&input_pay_id; v_salary first_pay_new.salary%TYPE; v_jobcode first_pay_new.jobcode%TYPE; v_bonus first_pay_new.bonus%TYPE; v_new_bonus first_pay_new.bonus%TYPE; BEGIN SELECT salary, jobcode, bonus INTO v_salary, v_jobcode, v_bonus FROM first_pay_new WHERE pay_id = v_pay_id; IF v_jobcode = 'CI' THEN IF v_salary > THEN v_new_bonus := v_bonus + 500; ELSE v_new_bonus := v_bonus + 250; END IF; ELSE IF v_jobcode = 'IN' THEN IF v_salary > THEN v_new_bonus := v_bonus + 250; ELSE IF v_salary > THEN v_new_bonus := v_bonus + 100; ELSE v_new_bonus := v_bonus + 50; END IF; ELSE IF v_jobcode = 'AP' THEN IF v_salary > THEN v_new_bonus := v_bonus + 100; END IF; IF v_new_bonus != v_bonus THEN UPDATE first_pay_new SET bonus = v_new_bonus WHERE pay_id = v_pay_id; END IF; END; / SET VERIFY ON PL/SQL - IF This is firstpay5. It is a series of embedded IF statements some with an ELSE and some without. NOTE that there is an IF before the update to see if a new bonus was calculated. If it was, then the update is done.
PL/SQL - IF IF v_new_bonus != v_bonus THEN UPDATE first_pay_new SET bonus = v_new_bonus WHERE pay_id = v_pay_id; END IF; END; / SET VERIFY ON SET VERIFY OFF DECLARE v_pay_id first_pay_new.pay_id%TYPE :=&input_pay_id; v_salary first_pay_new.salary%TYPE; v_jobcode first_pay_new.jobcode%TYPE; v_bonus first_pay_new.bonus%TYPE; v_new_bonus first_pay_new.bonus%TYPE; BEGIN SELECT salary, jobcode, bonus INTO v_salary, v_jobcode, v_bonus FROM first_pay_new WHERE pay_id = v_pay_id; IF v_jobcode = 'CI' THEN IF v_salary > THEN v_new_bonus := v_bonus + 500; ELSE v_new_bonus := v_bonus + 250; END IF; ELSE IF v_jobcode = 'IN' THEN IF v_salary > THEN v_new_bonus := v_bonus + 250; ELSE IF v_salary > THEN v_new_bonus := v_bonus + 100; ELSE v_new_bonus := v_bonus + 50; END IF; ELSE IF v_jobcode = 'AP' THEN IF v_salary > THEN v_new_bonus := v_bonus + 100; END IF;
PL/SQL - IF v_jobcode = CI v_salary > Increase bonus by 500 Increase bonus by 250 v_jobcode = IN v_salary > Increase bonus by 250 Increase bonus by 50 v_salary > Increase bonus by 100 v_jobcode = AP v_salary > Increase bonus by 100 Y Y Y Y Y Y Y N N N N N N N
SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC firstpay5 Enter value for input_pay_id: 5555 PL/SQL procedure successfully completed. SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC PL/SQL - IF This is the code that was executed to make the salary for employee 5555 increase by 500. IF v_jobcode = 'CI' THEN IF v_salary > THEN v_new_bonus := v_bonus + 500;
firstpay5 Enter value for input_pay_id: 7777 PL/SQL procedure successfully completed. SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC firstpay5 Enter value for input_pay_id: 3333 PL/SQL procedure successfully completed. SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC PL/SQL - IF Bonus was null so no activity. Bonus was increased by 100 because v_jobcode = AP and v_salary >
SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal NUMBER(7,2); v_newgoal NUMBER(7,2); v_state VARCHAR2(2); BEGIN SELECT yrgoal, state INTO v_yrgoal, v_state FROM donornew WHERE idno = v_idno; IF v_yrgoal > 250 AND v_state = 'MA' THEN v_newgoal := v_yrgoal * 1.1 ; ELSE v_newgoal := v_yrgoal * 1.2; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; END; / SET VERIFY ON SQL> edit donor3 PL/SQL - IF This is an example of a compound AND.
PL/SQL - Compound AND v_yrgoal > 250 v_state = MA Increase goal by 10% Increase goal by 20% Y Y N N Increase goal by 20% IF v_yrgoal > 250 AND v_state = 'MA' THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal * 1.2; END IF;
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa PL/SQL - Compound AND donor3 Enter value for input_idno: PL/SQL procedure successfully completed. SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa IF v_yrgoal > 250 AND v_state = 'MA' THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal * 1.2; END IF; Since goal was not greater than 250 the ELSE was executed and the goal was increased by 20%. Before After
PL/SQL - Compound AND SET VERIFY OFF DECLARE v_pay_id first_pay_new.pay_id%TYPE :=&input_pay_id; v_new_sal first_pay_new.salary%TYPE; v_jobcode first_pay_new.jobcode%TYPE; v_bonus first_pay_new.bonus%TYPE; BEGIN SELECT salary, jobcode, bonus INTO v_new_sal, v_jobcode, v_bonus FROM first_pay_new WHERE pay_id = v_pay_id; IF v_jobcode = 'CI' AND v_bonus > 1000 THEN v_new_sal := v_new_sal * 1.05; ELSE v_new_sal := v_new_sal * 1.02; END IF; UPDATE first_pay_new SET salary = v_new_sal WHERE pay_id = v_pay_id; END; / SET VERIFY ON SQL> edit firstpay6
v_jobcode=CI v_bonus > 1000 Increase salary by 5% Increase salary by 2% Y Y N N Increase salary by 2% PL/SQL - Compound AND IF v_jobcode = 'CI' AND v_bonus > 1000 THEN v_new_sal := v_new_sal * 1.05; ELSE v_new_sal := v_new_sal * 1.02; END IF;
SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC PL/SQL - Compound AND firstpay6 Enter value for input_pay_id: 5555 PL/SQL procedure successfully completed. SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC firstpay6 Enter value for input_pay_id: 1111 PL/SQL procedure successfully completed. firstpay6 Enter value for input_pay_id: 2222 PL/SQL procedure successfully completed.
PL/SQL - Compound OR SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal NUMBER(7,2); v_newgoal NUMBER(7,2); v_state VARCHAR2(2); BEGIN SELECT yrgoal, state INTO v_yrgoal, v_state FROM donornew WHERE idno = v_idno; IF v_yrgoal > 250 OR v_state = 'MA' THEN v_newgoal := v_yrgoal * 1.1 ; ELSE v_newgoal := v_yrgoal * 1.2; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; END; / SET VERIFY ON SQL> edit donor3a
v_yrgoal > 250 v_state = MA Increase goal by 10% Increase goal by 20% Y Y N N PL/SQL - Compound OR Increase goal by 10% IF v_yrgoal > 250 OR v_state = 'MA' THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal * 1.2; END IF;
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa donor3a Enter value for input_idno: PL/SQL procedure successfully completed. donor3a Enter value for input_idno: PL/SQL procedure successfully completed. SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa PL/SQL - Compound OR
SQL> edit firstpay7 SET VERIFY OFF DECLARE v_pay_id first_pay_new.pay_id%TYPE :=&input_pay_id; v_new_sal first_pay_new.salary%TYPE; v_jobcode first_pay_new.jobcode%TYPE; v_bonus first_pay_new.bonus%TYPE; BEGIN SELECT salary, jobcode, bonus INTO v_new_sal, v_jobcode, v_bonus FROM first_pay_new WHERE pay_id = v_pay_id; IF v_jobcode = 'CI' OR v_bonus > 1000 THEN v_new_sal := v_new_sal * 1.05; ELSE v_new_sal := v_new_sal * 1.02; END IF; UPDATE first_pay_new SET salary = v_new_sal WHERE pay_id = v_pay_id; END; / SET VERIFY ON
PL/SQL - Compound OR SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC Enter value for input_pay_id: 6666 PL/SQL procedure successfully completed. Enter value for input_pay_id: 3333 PL/SQL procedure successfully completed. Enter value for input_pay_id: 1111 PL/SQL procedure successfully completed.
SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal donornew.yrgoal%TYPE; v_newgoal donornew.yrgoal%TYPE; v_state donornew.state%TYPE; v_datefst donornew.datefst%TYPE; BEGIN SELECT yrgoal, state, datefst INTO v_yrgoal, v_state, v_datefst FROM donornew WHERE idno = v_idno; IF v_state = 'MA' AND (v_yrgoal '01-JAN-98') THEN v_newgoal := v_yrgoal * 1.1 ; ELSE v_newgoal := v_yrgoal; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; END; / SET VERIFY ON SQL> edit donor3b PL/SQL - compound AND / OR
v_state=MA v_yrgoal < 100 Increase goal by 10% No change to goal Y Y N N No change to goal v_datefst > 01-JAN-98 Increase goal by 10% YN IF v_state = 'MA' AND (v_yrgoal '01-JAN-98') THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal;
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa donor3b Enter value for input_idno: PL/SQL procedure successfully completed. donor3b Enter value for input_idno: PL/SQL procedure successfully completed. donor3b Enter value for input_idno: PL/SQL procedure successfully completed. SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa Record met the criteria and a change was made to the goal. Records and did not meet the criteria.
PL/SQL - compound AND / OR SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal donornew.yrgoal%TYPE; v_newgoal donornew.yrgoal%TYPE; v_state donornew.state%TYPE; v_datefst donornew.datefst%TYPE; BEGIN SELECT yrgoal, state, datefst INTO v_yrgoal, v_state, v_datefst FROM donornew WHERE idno = v_idno; IF v_state = 'MA' AND v_yrgoal '01-JAN-98' THEN v_newgoal := v_yrgoal * 1.1 ; ELSE v_newgoal := v_yrgoal; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; END; / SET VERIFY ON SQL> edit donor3c
v_state=MA v_yrgoal < 100 Increase goal by 10% No change to goal Y Y N N v_datefst > 01-JAN-98 Increase goal by 10% YN PL/SQL - compound AND / OR No change to goal v_datefst > 01-JAN-98 Increase goal by 10% YN IF v_state = 'MA' AND v_yrgoal '01-JAN-98' THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal; END IF;
v_state=MA v_yrgoal < 100 Increase goal by 10% No change to goal Y Y N N No change to goal v_datefst > 01-JAN-98 Increase goal by 10% YN PL/SQL - compound AND / OR IF v_datefst > '01-JAN-98’ OR v_state = 'MA' AND v_yrgoal < 100 THEN v_newgoal := v_yrgoal * 1.1; ELSE v_newgoal := v_yrgoal; END IF;
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa donor3c Enter value for input_idno: PL/SQL procedure successfully completed. donor3c Enter value for input_idno: PL/SQL procedure successfully completed. SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa PL/SQL - compound AND / OR
PL/SQL - null SET VERIFY OFF DECLARE v_idno VARCHAR2(5) :=&input_idno; v_yrgoal donornew.yrgoal%TYPE; v_newgoal donornew.yrgoal%TYPE; v_state donornew.state%TYPE; BEGIN SELECT yrgoal, state INTO v_yrgoal, v_state FROM donornew WHERE idno = v_idno; IF v_state = 'RI' AND (v_yrgoal < 100 OR v_yrgoal IS NULL) THEN v_newgoal := 100; ELSE v_newgoal := v_yrgoal; END IF; UPDATE donornew SET yrgoal = v_newgoal WHERE idno = v_idno; END; / SET VERIFY ON SQL> edit donor3d
SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN-98 Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa donor3d Enter value for input_idno: PL/SQL procedure successfully completed. SQL> SELECT * FROM donornew; IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT Stephen Daniels 123 Elm St Seekonk MA JUL John Smith Jennifer Ames 24 Benefit St Providence RI MAY Susan Jones Carl Hersey 24 Benefit St Providence RI JAN Susan Jones Susan Ash 21 Main St Fall River MA MAR Amy Costa Nancy Taylor 26 Oak St Fall River MA MAR John Adams Robert Brooks 36 Pine St Fall River MA APR Amy Costa PL/SQL - null Record is for RI and the yrgoal is null so it meets the criteria and the change is made.
SQL> edit firstpay8 PL/SQL - compound SET VERIFY OFF DECLARE v_pay_id first_pay_new.pay_id%TYPE :=&input_pay_id; v_new_sal first_pay_new.salary%TYPE; v_jobcode first_pay_new.jobcode%TYPE; v_bonus first_pay_new.bonus%TYPE; BEGIN SELECT salary, jobcode, bonus INTO v_new_sal, v_jobcode, v_bonus FROM first_pay_new WHERE pay_id = v_pay_id; IF v_jobcode = 'CI' AND v_bonus > 1500 OR v_jobcode = 'IN' AND v_bonus > 1000 THEN v_new_sal := v_new_sal * 1.05; END IF; UPDATE first_pay_new SET salary = v_new_sal WHERE pay_id = v_pay_id; END; / SET VERIFY ON
IF v_jobcode = 'CI' AND v_bonus > 1500 OR v_jobcode = 'IN' AND v_bonus > 1000 THEN v_new_sal := v_new_sal * 1.05; END IF; v_jobcode=CI v_bonus > 1500 Increase salary by 5% Y Y N N v_jobcode=IN YN PL/SQL - compound v_bonus > 1000 Increase salary by 5% YN
SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC firstpay8 Enter value for input_pay_id: 1111 PL/SQL procedure successfully completed. firstpay8 Enter value for input_pay_id: 5555 PL/SQL procedure successfully completed. SQL> SELECT * FROM first_pay_new; PAY_ NAME JO STARTDATE SALARY BONUS Linda Costa CI 15-JAN John Davidson IN 25-SEP Susan Ash AP 05-FEB Stephen York CM 03-JUL Richard Jones CI 30-OCT Joanne Brown IN 18-AUG Donald Brown CI 05-NOV Paula Adams IN 12-DEC firstpay8 Enter value for input_pay_id: 2222 PL/SQL procedure successfully completed. firstpay8 Enter value for input_pay_id: 8888 PL/SQL procedure successfully completed. PL/SQL - compound