SQLize Online / PHPize Online  /  SQLtest Online

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

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear