Question

Write PL/SQL Procedure that returns the names of people who spent over $100. Create table Resturauntorder...

Write PL/SQL Procedure that returns the names of people who spent over $100.

Create table Resturauntorder (

resturauntorder_id int,

resturaunt_name varchar2(50),

hotel_name varchar2(50),

customer_name varchar2(50),

order_date date,

items_orderd varchar2(100),

order_total decimal(5,2),

payment_type varchar2(50),

tip_amount decimal(5,2),

primary key(resturauntorder_id)

);

Insert into Resturauntorder values (123,'Terrace Restaurant', 'Hilton Palm Springs', 'John Smith', date '2019-01-10', 'Omelet Pan, Cinnamon French Toast, California eggs, Orange Juice', 60.49, 'cash', 10.33);

Insert into Resturauntorder values (345,'Spiaggia', 'Hilton Chicago/Magnificent Mile Suite','Ashley Scott', date '2019-02-21', 'Polpo, Tonno Vitellato, Rabarbaro', 189.29, 'credit', 36.00);

Insert into Resturauntorder values (672,'Ocean Prime', 'New York Hilton Midtown', 'James Lowry', date '2019-03-21', 'Lobster roll, Calamari, Chilled Whole Main Lobster', 125.33, 'credit', 31.25);


0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the SQL statement to create the PL/SQL procedure:

CREATE OR REPLACE
PROCEDURE CustomersSpentOver100(
crsr OUT SYS_REFCURSOR)
AS
BEGIN
    OPEN
crsr FOR
        SELECT customer_name, (order_total + tip_amount) AS "Amount Spent"
        FROM Resturauntorder
        WHERE (order_total + tip_amount) > 100;
END;

I have added, "Amount Spent" column in result to give a clear picture of the result, you may remove it if needed.

You can execute the above procedure using the below statement:

VARIABLE RC REFCURSOR;
EXEC CustomersSpentOver100( :RC );
PRINT RC;

Below is the result produced:

This completes the requirement. Let me know if you have any questions.

Thanks!

Add a comment
Know the answer?
Add Answer to:
Write PL/SQL Procedure that returns the names of people who spent over $100. Create table Resturauntorder...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT