lab05_output - SQL> SQL> -Step 1: Creating the First...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
SQL> SQL> --Step 1: Creating the First Trigger SQL> create or replace trigger RENTING_MOVIE after insert on mm_rental 2 for each row 3 BEGIN 4 update mm_movie set movie_qty=movie_qty-1 where movie_id=:old.movie_id; 5 END RENTING_MOVIE; 6 / Trigger created. SQL> SQL> --Step 2: Creating the Second Trigger SQL> create or replace trigger RETURNING_MOVIE after update on mm_rental 2 for each row 3 BEGIN 4 update mm_movie set movie_qty=movie_qty+1 where movie_id=:old.movie_id; 5 END RETURNING_MOVIE; 6 / Trigger created. SQL> --Step 3: Modifying the Package Code SQL> SQL> create or replace package MM_RENTALS_PKG AS 2 3 procedure MOVIE_RENTAL_SP ( 4 P_MOVIE_ID NUMBER, 5 P_MEMBER_ID NUMBER, 6 P_PAYMENT_METHODS_ID NUMBER 7 ); 8 9 procedure MOVIE_RETURN_SP 10 (p_rental_id NUMBER); 11 12 function MOVIE_STOCK_SF (p_movie_id NUMBER) 13 RETURN VARCHAR2; 14 END MM_RENTALS_PKG; 15 / Package created. SQL> SQL> create or replace package body MM_RENTALS_PKG AS 2 procedure MOVIE_RENTAL_SP ( 3 P_MOVIE_ID NUMBER, 4 P_MEMBER_ID NUMBER, 5 P_PAYMENT_METHODS_ID NUMBER 6 ) 7 AS 8 count_movie_id NUMBER; 9 count_member_id NUMBER; 10 count_payments NUMBER; 11 count_movie_qty NUMBER; 12 13 UNKNOWN_MOVIE EXCEPTION; 14 UNKNOWN_MEMBER EXCEPTION; 15 UNKNOWN_PAYMENT EXCEPTION; 16 UNAVAILABLE_MOVIE EXCEPTION; 17 18 BEGIN 19 select count(*) into count_movie_id from mm_movie where movie_id=p_movie_id; 20
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
21 if count_movie_id=0 22 then 23 RAISE UNKNOWN_MOVIE; 24 end if; 25 26 select count(*) into count_member_id from mm_member where member_id=p_member_id;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/29/2012 for the course DM DM450 taught by Professor Dm450 during the Spring '11 term at DeVry Long Beach.

Page1 / 5

lab05_output - SQL> SQL> -Step 1: Creating the First...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online