Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION "GELDIGE_AANWEZIGHEID_TIJD"
  2. (kind_id IN NUMBER,
  3. datum IN DATE,
  4. tijd IN NUMBER)
  5. RETURN BOOLEAN
  6. IS
  7. CURSOR c_aanwezigheden IS
  8. SELECT      "AANWEZIGHEID_TIJD"."AANKOMST" AS "AANKOMST",
  9.      "AANWEZIGHEID_TIJD"."VERTREK" AS "VERTREK"
  10.  FROM     "AANWEZIGHEID_TIJD" "AANWEZIGHEID_TIJD",
  11.      "AANWEZIGHEID" "AANWEZIGHEID"
  12.  WHERE   "AANWEZIGHEID_TIJD"."AANWEZIGHEID_ID"="AANWEZIGHEID"."AANWEZIGHEID_ID"
  13. AND
  14. "AANWEZIGHEID"."DATUM" = datum
  15. AND
  16. "AANWEZIGHEID"."KIND_ID" = kind_id;
  17.  
  18. begin_tijd TIMESTAMP;
  19. eind_tijd TIMESTAMP;
  20. nieuwe_tijd TIMESTAMP;
  21. BEGIN
  22. FOR aanwezigh IN c_aanwezigheden
  23. LOOP
  24.    IF aanwezigh.vertrek IS NULL THEN
  25. RETURN FALSE;
  26. END IF;
  27. begin_tijd := TO_TIMESTAMP(datum ||' '||aanwezigh.aankomst, 'MM/DD/YYYY HHMI');
  28. eind_tijd := TO_TIMESTAMP(datum ||' '||aanwezigh.vertrek, 'MM/DD/YYYY HHMI');
  29. nieuwe_tijd := TO_TIMESTAMP(datum ||' '||tijd, 'MM/DD/YYYY HHMI');
  30.  
  31. IF nieuwe_tijd BETWEEN begin_tijd AND eind_tijd THEN
  32. RETURN FALSE;
  33. END IF;
  34. END LOOP;
  35. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement