Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I completed this question using the hints from the comment but still have an error at DELIMITER// Error Code: 1064. You have an error in

I completed this question using the hints from the comment but still have an error at DELIMITER//

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 5 which is DELIMITER//

DROP PROCEDURE IF EXISTS Set_VIP_status;

DELIMITER // /* ForestGlenInn has a VIP progam. Set the status for a given guest, based on number of reservations - If the guest has stayed more than 3 times, they get GOLD status - If the guest has stayed 3 times, they get SILVER status - If the guest has stayed twice, they get a BRONZE status - If they have not stayed or have only stayed once, they are not a VIP */ CREATE PROCEDURE Set_VIP_status ( /* one input parameters for guest ID */ guest_id_param INT ); BEGIN DECLARE sql_error INT DEFAULT FALSE; DECLARE num_stays_var INT; DECLARE VIP_status_var VARCHAR(10); DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET sql_error = TRUE; /* Default to 'Not a VIP' */ SET VIP_status_var = 'Not a VIP'; /* calculate the number of reservations */ /* HINT: write a SELECT statement which queries the reservations table using the guest_id parameter. Use the INTO keyword to store the number of stays into the local variable num_stays_var declared above */ SELECT num_stays INTO num_stays_var FROM reservations WHERE guest_id=guest_id_param; /* calculate the VIP status */ /* HINT: use a sequence of IF/ELSEIF statements to assign the VIP_status_var based on num_stays */ IF num_stays_var > 3 THEN

SET VIP_status_var = 'GOLD';

ELSEIF num_stays_var = 3 THEN

SET VIP_status_var = 'SILVER';

ELSEIF num_stays_var = 2 THEN

SET VIP_status_var = 'BRONZE';

START TRANSACTION;

/* update the VIP status for this guest */ /* HINT: write an UPDATE statement against the guests table using VIP_status_var and guest_id_param */ UPDATE guests SET VIP_status = VIP_status_var WHERE guest_id = guest_id_param; IF sql_error = FALSE THEN COMMIT; ELSE ROLLBACK;

DELIMITER ;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

What is loss of bone density and strength as ?

Answered: 1 week ago

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago

Question

=+ a. A change in consumer preferences increases the saving rate.

Answered: 1 week ago