j A L
2010-12-08 12:12:06 UTC
Member_ID NUMBER PRIMARY KEY,
First_Name VARCHAR2(25),
Last_Name VARCHAR2(25),
Street VARCHAR2(25),
City VARCHAR2(15),
Phone CHAR(11),
Valid_Date DATE,
message VARCHAR2(200))
/
create table TITLE_COPY(
Copy_ID NUMBER,
Title_ID NUMBER,
Status VARCHAR2(30),
Title_Name VARCHAR2(20),
constraint TITLE_COPY_PK PRIMARY KEY(Copy_ID,Title_ID))
/
create table RENTAL(
Book_Date DATE,
Copy_ID NUMBER,
Member_ID NUMBER,
Title_ID NUMBER,
Act_Return_Date DATE,
Exp_Return_Date DATE,
constraint RENTAL_PK PRIMARY KEY(Book_Date, Copy_ID),
constraint RENTAL_FK FOREIGN KEY(Copy_ID,Title_ID) references TITLE_COPY(Copy_ID,Title_ID) on delete cascade)
/
create table RESERVATION(
Reserve_Date DATE,
Member_ID NUMBER,
Title_ID NUMBER)
/
I understand that I need to check if the video status of my OUT is in and if sql%notfound then i need to insert info into a reservation table. but if the video is in, i need to update status to out. here is what I got so far, not sure if this is the best way to do it.
Create or replace procedure checkout (
p_memberid IN member.member_id%type,
p_titleNum IN rental.title_id%type
p_video_status OUT title_copy.status%type )
is
cnumber number;
titleNum number;
cursor c1 is
select member_id
from member
where member_id = p_memberid;
cursor c2 is
select title_id
from rental
where title_id = p_titleNum;
begin
open c1;
fetch c1 into cnumber;
close c1;
open c2;
fetch c2 into titleNum;
close c2;
here are my objectives:
procedure name is checkout
pass in customer member# and title# into checkout procedure
update video status to OUT if the video is available.
populate a new checkout record into rental table.
populate a new reservation record into reservation table if the video is not available.