I have the following stored procedure which is executed correctly (in the first time) from MySQL workbench and from my QT application:
DROP PROCEDURE IF EXISTS mprocedure;
DELIMITER $$
CREATE PROCEDURE mprocedure()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
SELECT 'An exception occurred';
END;
DECLARE EXIT HANDLER FOR SQLSTATE '23000'
BEGIN
ROLLBACK;
SELECT 'Unique Record Duplication occured, all saved records will be deleted from all other tables';
END;
START TRANSACTION;
INSERT INTO `My_schema`.`cus`(`Health insurance number`,`discount percentage`,`max discount`)VALUES('88520000000000','.9','.99');
INSERT INTO `My_schema`.`per`(`sex`,`Socialstatus`,`firstdate`,`cus_id_cus`)values( 'male', 'single', '2018-01-01 00:00:00', LAST_INSERT_ID());
commit;
END;
$$
DELIMITER ;
call mprocedure();
DROP PROCEDURE IF EXISTS mprocedure;
DELIMITER $$
CREATE PROCEDURE mprocedure()
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
SELECT 'An exception occurred';
END;
DECLARE EXIT HANDLER FOR SQLSTATE '23000'
BEGIN
ROLLBACK;
SELECT 'Unique Record Duplication occured, all saved records will be deleted from all other tables';
END;
START TRANSACTION;
INSERT INTO `My_schema`.`cus`(`Health insurance number`,`discount percentage`,`max discount`)VALUES('88520000000000','.9','.99');
INSERT INTO `My_schema`.`per`(`sex`,`Socialstatus`,`firstdate`,`cus_id_cus`)values( 'male', 'single', '2018-01-01 00:00:00', LAST_INSERT_ID());
commit;
END;
$$
DELIMITER ;
call mprocedure();
To copy to clipboard, switch view to plain text mode
but when i tried to execute the previous again, i had 3 cases:
1. If the call was from MySQL workbench, it gave me the error that is supposed to be received
"Unique Record Duplication occurred, all saved records will be deleted from all other tables"
"Unique Record Duplication occurred, all saved records will be deleted from all other tables"
To copy to clipboard, switch view to plain text mode
2. But if the call was from QT app, it should give me the same error but unfortunately gave me nothing.
3. If i used
call mprocedure();
call mprocedure();
To copy to clipboard, switch view to plain text mode
instead of the whole previous string, it worked well.
Any help is appreciated
Bookmarks