Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.08 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE PERIODE_MINSTE_OPNAMES
  2. IS
  3.   TYPE type_coll_periodes IS TABLE OF periode%ROWTYPE;
  4.   t_periodes type_coll_periodes;
  5.   v_index PLS_INTEGER;
  6. BEGIN
  7.   SELECT pe.*
  8.   BULK COLLECT INTO t_periodes
  9.   FROM Periode pe
  10.   WHERE pe.begindatum IN(SELECT pe1.begindatum
  11.                          FROM Periode pe1, Opname op1
  12.                          WHERE op1.datum BETWEEN pe1.begindatum AND pe1.einddatum
  13.                          HAVING COUNT(op1.rolnr) =
  14.                               (SELECT MIN(COUNT(op2.rolnr))
  15.                                FROM Opname op2, Periode pe2
  16.                                WHERE op2.datum BETWEEN pe2.begindatum AND pe2.einddatum
  17.                                GROUP BY pe2.begindatum)
  18.                          GROUP BY pe1.begindatum);
  19.  
  20.   v_index := t_periodes.FIRST;
  21.  
  22.   WHILE v_index IS NOT NULL
  23.   LOOP
  24.     DBMS_OUTPUT.PUT_LINE(t_periodes(v_index).begindatum || ' ' || t_periodes(v_index).einddatum || ' ' || t_periodes(v_index).plaatsnaam);
  25.    
  26.     v_index := t_periodes.next(v_index);
  27.   END LOOP;
  28. END PERIODE_MINSTE_OPNAMES;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement