i have modified it to be :
DROP PROCEDURE IF EXISTS mprocedure;
DELIMITER $$
CREATE PROCEDURE mprocedure ()
BEGIN
START TRANSACTION;
INSERT INTO `mschema`.`table1`
(`maxbudget`,
`blocked`,
`d_percentage`,
`max discount`)
VALUES
('2250',
'0',
'.9',
'.99');
if (@@error_count = 0 ) then
INSERT INTO `mschema`.`table2`
(`name`,`image`,`date`,`fKey_id`)
values
('jhon','jfdd', '2018-01-01 00:00:00', LAST_INSERT_ID());
if (@@error_count = 0 ) then
commit;
else
rollback;
end if;
else rollback;
end if;
commit;
END;
$$
DELIMITER ;
and tried to call the function twice, in the first time of its execution, the 2 records in the 2 different database was saved and committed ans in the next time of execution, an error occurred:
Error Code: 1062. Duplicate entry '21390556321230' for key ....
and i wanted to make sure that
rollback has worked well, but unfortunately
rollback did not revert the record saved in the first table