Task: UPDATE all employees salary in department 40 or 60 depending on their current salary range. Create a cursor and load all the records belongs to employees who works in department either in 40 or 60

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Please use sql to answer the follwoing question (an erd has also been add)

Task 2:

  1. Task: UPDATE all employees salary in department 40 or 60 depending on their current salary range.

Create a cursor and load all the records belongs to employees who works in department either in 40 or 60

  1. a) Include employee_id, last_name, department_id and salary in Cursor SELECT

Cursor cur_emp1 IS

SELECT employee_id, last_name, department_id, salary FROM EMPLOYEES

WHERE department_id IN (40,60);

  1. b) Now inside BEGIN and END block

create CURSOR FOR LOOP with k keyword.

FOR k IN cur_emp1

    LOOP

END LOOP;

  1. now inside above for loop check each records salary

IF

If employee salary is less than 5000 then add 20% of their salary and update actual phsyical table

                      update employees SET salary= salary*1.20

                      WHERE employee_id = k.salary;

            Else if if employee salary is less then 8000 add 15%

                            update employees SET salary= salary*1.15

                           WHERE employee_id = k.salary;

               everything else  THEN add 10%  to their salary .. change their salary in the actual table.

 END IF;

DEPARTMENTS
LOCATIONS
* DEPARTMENT_ID
* DEPARTMENT_NAME
MANAGER_ID
LOCATION_ID
P
* LOCATION_ID
STREET_ADDRESS
POSTAL_CODE
* CITY
JOB_HISTORY
F
F
PF * EMPLOYEE_ID
P
START_DATE
* END_DATE
F * JOB_ID
STATE_PROVINCE
IF
COUNTRY_ID
F
DEPARTMENT_ID
EMPLOYEES
P
ΕMPLOYEEID
FIRST_NAME
LAST_NAME
U * EMAIL
COUNTRIES
P
COUNTRY_ID
COUNTRY_NAME
REGION_ID
PHONE_NUMBER
HIRE_DATE
F
F
JOBS
JOB_ID
* JOB_TITLE
MIN_SALARY
MAX_SALARY
* JOB_ID
SALARY
COMMISSION_PCT
REGIONS
F
MANAGER_ID
F
IP
REGION_ID
REGION_NAME
DEPARTMENT_ID
Transcribed Image Text:DEPARTMENTS LOCATIONS * DEPARTMENT_ID * DEPARTMENT_NAME MANAGER_ID LOCATION_ID P * LOCATION_ID STREET_ADDRESS POSTAL_CODE * CITY JOB_HISTORY F F PF * EMPLOYEE_ID P START_DATE * END_DATE F * JOB_ID STATE_PROVINCE IF COUNTRY_ID F DEPARTMENT_ID EMPLOYEES P ΕMPLOYEEID FIRST_NAME LAST_NAME U * EMAIL COUNTRIES P COUNTRY_ID COUNTRY_NAME REGION_ID PHONE_NUMBER HIRE_DATE F F JOBS JOB_ID * JOB_TITLE MIN_SALARY MAX_SALARY * JOB_ID SALARY COMMISSION_PCT REGIONS F MANAGER_ID F IP REGION_ID REGION_NAME DEPARTMENT_ID
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education