Advertisement
Jgug

PROCEDURE_01

Dec 14th, 2014
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.77 KB | None | 0 0
  1. -- Процедура вычисления зарплаты и занесения в таблицу
  2. CREATE OR REPLACE
  3. PROCEDURE COUNTSALARY(SALARYONE NUMBER)
  4. IS
  5.     CURSOR PERSONNEL_CONTRACTS IS
  6.         SELECT C.PERSONNEL_ID AS ID, COUNT(*) AS CONTRACTS
  7.         FROM Contracts C
  8.         GROUP BY C.PERSONNEL_ID;
  9.     PERS PERSONNEL_CONTRACTS%ROWTYPE;
  10. BEGIN
  11.     OPEN PERSONNEL_CONTRACTS;
  12.     LOOP
  13.         FETCH PERSONNEL_CONTRACTS INTO PERS;
  14.         INSERT INTO SALARY VALUES (PERS.ID, PERS.CONTRACTS*SALARYONE);
  15.         EXIT WHEN PERSONNEL_CONTRACTS%NOTFOUND;
  16.     END LOOP;
  17.     COMMIT;
  18.     CLOSE PERSONNEL_CONTRACTS;
  19. EXCEPTION
  20.     WHEN OTHERS THEN
  21.     RAISE_APPLICATION_ERROR(-20001, 'An error - '||SQLCODE||' - ERROR - '||SQLERRM);
  22. END COUNTSALARY;
  23.  
  24. -- Выполнение процедуры
  25. BEGIN
  26.     COUNTSALARY(80);
  27. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement