Advertisement
jurek224466

zadanie_257

Dec 3rd, 2020 (edited)
1,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.73 KB | None | 0 0
  1. //zadanie 257
  2. DECLARE CURSOR c_studenci IS
  3. SELECT
  4.   id_student,
  5.   nazwisko,
  6.   imie
  7. FROM
  8.   studenci;
  9. currentnumber NUMBER;
  10. FUNCTION Sumpoints (pids studenci.id_student % TYPE) RETURN NUMBER IS points NUMBER;
  11. BEGIN
  12. SELECT
  13.   SUM(punkty) INTO points
  14. FROM
  15.   egzaminy
  16. WHERE
  17.   id_student = pids;
  18. IF points IS NULL THEN points := -1;
  19. END IF;
  20. RETURN points;
  21. END;
  22. BEGIN FOR student IN c_studenci LOOP currentnumber := Sumpoints(student.id_student);
  23. IF currentnumber >= 0 THEN DBMS_OUTPUT.Put_line(
  24.   student.nazwisko || ' ' || student.imie || ' uzyskal ilosc pkt: ' || currentnumber
  25. );
  26. ELSE DBMS_OUTPUT.Put_line(
  27.   student.nazwisko || ' ' || student.imie || ' nie podchodzil do egzaminu'
  28. );
  29. END IF;
  30. END LOOP;
  31. END;
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement