Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 19th, 2003, 12:53 AM
carly_1 carly_1 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 carly_1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help with PL/SQL

hey can anyone help me with PL/SQL statements i am having trouble with. Our assignment is a video shop database.
this is what i'm trying to do....

Write a procedure called DUE_FILMS that accepts a date (in DD/MM/YYYY format) that will determine the films that are either overdue or due back on that day. The procedure must display the film title, format, copy number, customer’s name and contact number, the date it was rented and due, the number of days it is overdue and the fine due. The output should be in date due order (most overdue film first). The data should also be written in UPPERCASE to a table called FILMS_DUE_AND_OVERDUE.

this is what i have for it....

create or replace procedure due_films(overdue_date IN DATE)
IS
cursor c1 is
select fr.date_rented, fr.date_due, c.cust_firstname, c.cust_lastname, c.cust_contact, f.film_title, f.classification, fc.format, fc.copy_nbr
from film_rental fr, customer c, film f, film_copy fc
where fr.customer_nbr = c.customer_nbr
and fr.film_id = f.film_id
and fr.film_id = fc.film_id
and date_due = overdue_date;
rented_date DATE;
due_date DATE;
cus_lastname VARCHAR(15);
cus_firstname VARCHAR(15);
contact VARCHAR(9);
title VARCHAR(20);
class VARCHAR(2);
f_mat VARCHAR(3);
copy_num NUMBER(4);
begin
open c1;
for i in 1..100 LOOP
fetch c1 INTO rented_date, due_date, cus_lastname, cus_firstname,contact, title, class, f_mat, copy_num;
exit when c1%NOTFOUND;
dbms_output.put_line(rented_date||' '||due_date||' '||cus_lastname||' '||cus_firstname||' '||contact||' '||title||' '||class||' '||f_mat||' '||copy_num);
end loop;
close c1;
end;



but the data i get is like when you dont have a join in and it creates a cartesian product...

17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G DVD 1
17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G VHS 1
17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G VHS 2
17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G VHS 3
17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G VHS 4
17/OCT/03 19/OCT/03 JOHN SMITH 59736454 CONAIR G VHS 5


i'm not sure what i'm doing wrong...........can anybody help........please

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > help with PL/SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway