Vote count:
0
hey guys can someone point me whats wrong in my mysql code im trying to create a stored procedure called in a trigger were a user insert a new book in the books table, the bookqty table insert if callNumber does not exist and updates when exist, but in some point the insert query is not working but the update query works fine thank you in advance
use librarydb; drop procedure if exists intoBooksQty; delimiter $$
create procedure intoBooksQty(in newcallNumber varchar(10))
begin
if not exists (select * from books where callNumber = newcallNumber) then
insert into librarydb.bookqty(callNumber,bookQty,bookqtyOut) values (newcallNumber, 1,0);
else
update bookqty set bookQty = bookQty + 1 where callNumber = newCallNumber;
end if;
end$$
delimiter ;
asked 29 secs ago
IF NOT EXIST and Insert mysql stored procedure
Aucun commentaire:
Enregistrer un commentaire