MySQL Forums
Forum List  »  Stored Procedures

Stored Procedure Syntax
Posted by: Naveen M
Date: May 08, 2016 02:16AM

Below is the table i have

CREATE TABLE car_rentals(
plate varchar(10) NOT NULL,
start_date date NOT NULL,
end_date date NOT NULL,
license_nr varchar(10) NOT NULL,
CONSTRAINT unq_car_rentals_start UNIQUE (plate, start_date),
CONSTRAINT unq_car_rentals_end UNIQUE (plate, end_date)

Need SP for the below scenario



stored procedure which takes as input aplate,
startdate andenddate and throws an error if tablecarrental contains any row with the same plate
where the rental period is different from but overlaps with the given period.

Note: Bycheckingonlyfordifferentrentalperiodswedon’tneedtoworryaboutthenewlyinsertedorupdated
tuple using the procedure in a trigger (see next question). Duplicate periods are already prevented by the
uniqueness constraints specified.

Options: ReplyQuote


Subject
Views
Written By
Posted
Stored Procedure Syntax
2034
May 08, 2016 02:16AM
452
May 08, 2016 05:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.