Indefinite Loop
Decodes the codes J
DECLARE
TYPE
EmpRecord
IS
RECORD (ssn employee.ssn%TYPE,
LName employee.LName%TYPE,
DName department.DName%TYPE,
BonusPayment NUMBER(6));
InactiveEmp EmpRecord;
EmpsRemaining PLS_INTEGER;
BEGIN
LOOP
SELECT
essn, LName,
DName, 0
INTO
InactiveEmp
FROM
employee, department,
works_on
WHERE
employee.dno =
department.dnumber
AND
employee.ssn =
works_on.essn
AND
hours = (SELECT MIN(hours) FROM works_on)
AND
ROWNUM <= 1;
UPDATE
department
SET
MgrSSN = NULL
WHERE
MgrSSN = InactiveEmp.ssn;
UPDATE employee
SET
SuperSSN = NULL
WHERE
SuperSSN = InactiveEmp.ssn;
DELETE
FROM dependent
WHERE
essn = InactiveEmp.ssn;
DELETE
FROM works_on
WHERE
essn = InactiveEmp.ssn;
DELETE
FROM employee
WHERE
ssn = InactiveEmp.ssn;
COMMIT;
dbms_output.put_line ('Inactive employee has been
transferred: ' ||
InactiveEmp.LName);
SELECT
COUNT(*)
INTO
EmpsRemaining
FROM
employee;
EXIT
WHEN EmpsRemaining <=
5;
END
LOOP;
END;
anonymous block completed
Inactive employee has been
transferred: Umer
Inactive employee has been
transferred: Ahmed
Inactive employee has been
transferred: Sana
Inactive employee has been
transferred: Rafique
Inactive employee has been
transferred: Khizer
No comments:
Post a Comment