0

HELLO, in my database, i have the following table:

video_hire(vide_hire_id,, hire_date, video_code, Cust_membship_no, returning_date, hire_cost)

video_code is (fk) ref: to VIDEO_LIST,
cust_membship_no is(fk) ref: Customers

IM TRYING TO code a PROCEDURE or FUNCTION TO to calculate the ammount of hire from one customer, and print the total, as well the customer details.
for example, if the customer hired 2 videos, it would have to different hire cost, so it would calculate the values and print the total ammount to pay.

im just learn and i find difficult to get it righ, i have look all over the forum there is no such answer. PLEASE HELP ME IF YOU CAN.

he is how i have estart my code:

CREATE PROCEDURE TOTAL
RETURNS (Total_hire DECIMAL(8,2))
AS
BEGIN
SELECT SUM(hire_cost)
FROM video_hire
INTO :Total_hire;
END;
SET TERM;

I know there is other ways to do but i cant get it right.

THANKS EVERY ONE.

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by mishiamej
0

I will like you to read a bit on how to write a good function and then a good procedure to know what you really want to use to solve the problem. Note that functions have a return value but procedures do not have a return value. You should also sum the select that will display the videos bought by a person you should use the primary key of an individual and then use that to get all the videos that individual has purchased. I hope this helps. If you do not get something right. I will be willing to help. ;)

mishiamej

Edited by Ezzaral: Snipped links. Keep it on site.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.