SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
DELIMITER $$ CREATE FUNCTION function1() RETURNS INT BEGIN -- Function 1 logic RETURN 1; END$$ ; CREATE FUNCTION function2() RETURNS VARCHAR(50) BEGIN -- Function 2 logic RETURN 'Hello'; END$$ DELIMITER ; -- DELIMITER $$ -- drop TRIGGER if exists `AddToBookStock`$$ -- CREATE TRIGGER `AddToBookStock` AFTER INSERT ON `BookAddition` -- FOR EACH ROW -- BEGIN -- Update BookStock set Copies = Copies+new.copies -- WHERE BranchId=new.BranchId and BookId=new.BookId; -- END$$ -- ; -- DELIMITER $$ -- drop TRIGGER if exists `DeleteFromBookStock`$$ -- CREATE TRIGGER `DeleteFromBookStock` AFTER DELETE ON `BookAddition` -- FOR EACH ROW -- BEGIN -- UPDATE BookStock set Copies = Copies-old.copies -- WHERE BranchId=old.BranchId and BookId=old.BookId; -- END$$ -- DELIMITER ;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear