Advertisement
Guest User

Untitled

a guest
May 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. CREATE OR REPLACE PACKAGE school_api as
  2. v_current_date DATE;
  3. PROCEDURE Discount_Cost;
  4. FUNCTION new_instructor_id RETURN instructor.instructor_id%TYPE;
  5. END school_api;
  6. /
  7. CREATE OR REPLACE PACKAGE BODY school_api AS
  8. PROCEDURE discount_cost IS
  9. CURSOR c_group_discount IS
  10. SELECT DISTINCT
  11. s.course_no,
  12. c.description
  13. FROM
  14. section s,
  15. enrollment e,
  16. course c
  17. WHERE
  18. s.section_id = e.section_id
  19. GROUP BY
  20. s.course_no,
  21. c.description,
  22. e.section_id,
  23. s.section_id
  24. HAVING
  25. COUNT(*) >= 8;
  26.  
  27. BEGIN FOR r_group_discount IN c_group_discount LOOP UPDATE course
  28. SET
  29. cost = cost *.95
  30. WHERE
  31. course_no = r_group_discount.course_no;dbms_output.put_line( 'A 5% discount has been given to'
  32. ||r_group_discount.course_no
  33. ||r_group_discount.description);
  34. END LOOP;
  35. END discount_cost;
  36. FUNCTION new_instructor_id RETURN instructor.instructor_id%TYPE IS
  37. v_new_instid instructor.instructor_id%TYPE;
  38. BEGIN
  39. SELECT INSTRUCTOR_ID_SEQ.NEXTVAL
  40. INTO v_new_instid
  41. FROM dual;
  42. RETURN v_new_instid;
  43. EXCEPTION
  44. WHEN OTHERS THEN
  45. DBMS_OUTPUT.PUT_LINE('Error ! ');
  46. END new_instructor_id;
  47. BEGIN
  48. SELECT trunc(sysdate, ' dd')
  49. INTO v_current_date
  50. FROM dual;
  51. END school_api;
  52. /
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement