SP assignemt - Q1 You have the following tables Book(ISBN title edition Member(ID m_name age ReserveBook(I_SBN i_d date Create a procedure that accept

SP assignemt - Q1 You have the following tables Book(ISBN...

This preview shows page 1 - 2 out of 2 pages.

Q1: You have the following tables: Book (ISBN, title, edition) Member (ID, m_name, age) ReserveBook (I_SBN, i_d, date) Create a procedure that accept the book title and list all the member names that borrowed this book. The procedure should return error message if title is missing or not found. create or replace procedure listmembers(tit in book.title%type) As cnt number; names varchar2(100); CURSOR borrow_members IS select m_name into names from member, book, reservebook where reservebook.id=member.ID and book.ISBN=reservebook.ISBN and title=tit; begin select count(*) into cnt from book where title=tit; if tit is null then begin dbms_output.put_line('title is null'); return; end; end if; if cnt=0 then begin dbms_output.put_line('title doesnt exists'); return; end; end if; OPEN borrow_members; LOOP FETCH borrow_members INTO names; EXIT WHEN borrow_members %NOTFOUND; dbms_output.put_line(names||' borrowed'||' '||tit); END LOOP; CLOSE borrow_members; end listmembers; begin listmembers('db'); end; Q2: You have the following tables: Hotel (H_id, h_name, contactperson) Room (R_id, Floor_no, occupied)
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Fall '08
  • 5odfatrek
  • Following, Articles with example SQL code, Stored procedure, following tables

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes