Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Процедура вычисления зарплаты и занесения в таблицу
- CREATE OR REPLACE
- PROCEDURE COUNTSALARY(SALARYONE NUMBER)
- IS
- CURSOR PERSONNEL_CONTRACTS IS
- SELECT C.PERSONNEL_ID AS ID, COUNT(*) AS CONTRACTS
- FROM Contracts C
- GROUP BY C.PERSONNEL_ID;
- PERS PERSONNEL_CONTRACTS%ROWTYPE;
- BEGIN
- OPEN PERSONNEL_CONTRACTS;
- LOOP
- FETCH PERSONNEL_CONTRACTS INTO PERS;
- INSERT INTO SALARY VALUES (PERS.ID, PERS.CONTRACTS*SALARYONE);
- EXIT WHEN PERSONNEL_CONTRACTS%NOTFOUND;
- END LOOP;
- COMMIT;
- CLOSE PERSONNEL_CONTRACTS;
- EXCEPTION
- WHEN OTHERS THEN
- RAISE_APPLICATION_ERROR(-20001, 'An error - '||SQLCODE||' - ERROR - '||SQLERRM);
- END COUNTSALARY;
- -- Выполнение процедуры
- BEGIN
- COUNTSALARY(80);
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement