Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET SERVEROUTPUT ON;
- DECLARE
- --Define the RECORD object
- TYPE EmpRecord
- IS RECORD (ssn employee.ssn%TYPE,
- LName employee.LName%TYPE,
- DName department.DName%TYPE,
- BonusPayment NUMBER(6)
- );
- --Declare variables
- ActiveEmp EmpRecord;
- InactiveEmp EmpRecord;
- BEGIN
- <<LocateActive>>
- SELECT essn, LName, DName, 5000
- INTO ActiveEmp
- FROM employee emp
- INNER JOIN department dep ON emp.dno = dep.dnumber
- INNER JOIN works_on wo ON emp.ssn = wo.essn
- WHERE
- hours = (SELECT MAX(hours) FROM works_on)
- AND ROWNUM <= 1;
- <<OutputActive>>
- DBMS_OUTPUT.put_line('Active employee name: ' || ActiveEmp.LName);
- DBMS_OUTPUT.put_line('Active employee department: ' || ActiveEmp.DName);
- DBMS_OUTPUT.put_line('Active employee bonus: $' || ActiveEmp.BonusPayment);
- <<LocateInactive>>
- SELECT essn, LName, DName, 0
- INTO ActiveEmp
- FROM employee emp
- INNER JOIN department dep ON emp.dno = dep.dnumber
- INNER JOIN works_on wo ON emp.ssn = wo.essn
- WHERE
- hours = (SELECT MIN(hours) FROM works_on)
- AND ROWNUM <= 1;
- --Test whether the Active and Inactive individual are the same
- IF ActiveEmp.ssn = InactiveEmp.ssn THEN
- GOTO Conclusion;
- END IF;
- <<OutputActive>>
- DBMS_OUTPUT.put_line('');
- DBMS_OUTPUT.put_line('Inactive employee name: ' || InactiveEmp.LName);
- DBMS_OUTPUT.put_line('Inactive employee department: ' || InactiveEmp.DName);
- DBMS_OUTPUT.put_line('Inactive employee bonus: $' || InactiveEmp.BonusPayment);
- <<Conclusion>>
- NULL;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement