add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE Workshop
(location Text, numPlaces int , numOperations int
)
INSERT INTO Workshop VALUES ('A',9,8)
CREATE TABLE Operation (idoperation int, workLocation Text)
CREATE TRIGGER before_Operation_insert
BEFORE INSERT
ON Operation FOR EACH ROW
BEGIN
DECLARE Placescount_ INT;
DECLARE Operationscount_ INT;
SELECT numPlaces, numOperations
INTO Placescount_,Operationscount_
FROM Workshop WHERE location = NEW.workLocation;
IF Placescount_ < Operationscount_ THEN
UPDATE Workshop
SET numOperations = numOperations + 1;
ELSE
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Maximum Number of Operarations reached in location ';
END IF;

END
INSERT INTO Operation VALUES (1,'A')
Maximum Number of Operarations reached in location