Guest User

Untitled

a guest
May 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. CREATE OR REPLACE PROCEDURE GEM_GRADE
  2. (p_sectionID IN section.section_id%TYPE,
  3. p_grade_type IN grade.grade_type_code%TYPE)
  4. AS
  5. TYPE type_stud IS RECORD
  6. (voornaam student.first_name%type,
  7. achternaam student.last_name%TYPE);
  8.  
  9. TYPE type_curs IS RECORD
  10. (nummer course.course_no%TYPE,
  11. beschrijving course.description%TYPE);
  12.  
  13. TYPE type_coll_grades
  14. IS TABLE OF grade%ROWTYPE
  15. INDEX BY PLS_INTEGER;
  16.  
  17. t_grades type_coll_grades;
  18. r_stud type_stud;
  19. r_curs type_curs;
  20. BEGIN
  21.  
  22. SELECT *
  23. BULK COLLECT INTO t_grades
  24. FROM grade
  25. WHERE (p_sectionid = section_id
  26. AND grade_type_code = p_grade_type);
  27.  
  28. FOR i IN 1..t_grades.COUNT
  29. LOOP
  30. SELECT first_name, last_name
  31. INTO r_stud.voornaam, r_stud.achternaam
  32. FROM student
  33. WHERE student_id = t_grades(i).student_id;
  34.  
  35. SELECT description, course_no
  36. INTO r_curs.beschrijving, r_curs.nummer
  37. FROM course
  38. WHERE course_no = (
  39. SELECT course_no
  40. FROM section
  41. WHERE section_id = t_grades(i).section_id);
  42.  
  43. dbms_output.put_line(
  44. 'Section ' || p_section_id || ' - ' || r_curs.beschrijving
  45. || ' #' || r_curs.nummer || ' > Student ' ||
  46. r_stud.achternaam || ' ' || r_stud.voornaam ||
  47. ' Score on ' || p_grade_type || ': ' || t_grades(i).numeric_grade
  48. );
  49.  
  50.  
  51. END LOOP;
  52. END GEM_GRADE;
Add Comment
Please, Sign In to add comment