0

I am creating a procedure in MySQL and need it to either, finish all the way through or give an error without committing anything to memory.

DELIMITER //
CREATE PROCEDURE input_package(n VARCHAR(255), p INT, l INT, d TEXT)
  BEGIN
  DECLARE i INT;
    START TRANSACTION;
      INSERT INTO java_master (name, description) VALUES (n, d);
      SET i = (SELECT id FROM java_master WHERE name = n AND description = d);
      INSERT INTO java_package (master_id, parent_package_id, library_id) VALUES (i, p, l);
    COMMIT;
  END //
DELIMITER ;

but when I tested if the second insert statement failed, then the first one still completed, this is a problem, and I am not sure what to do about it...

any suggestions would be great

  • check this: http://stackoverflow.com/questions/19905900/mysql-transaction-roll-back-on-any-exception might help! – Deepesh Feb 17 '15 at 07:52
  • great that worked, however now I have a weird problem, If I do get an error, it is not displayed... I'm not sure why not but I also haven't really tried to fix it yet, any suggestion would be great but I'm not holding breath haha. – Totalllyrandomguy Feb 17 '15 at 08:20
  • what is not being displayed? the error? I didn't get you – Deepesh Feb 17 '15 at 08:28
  • the error is not displayed, however I am using a client to read my code and interpret it for me, so chances are the problem is with the client... I'll if I used the command prompt for this it would likely work. – Totalllyrandomguy Feb 17 '15 at 17:38

0 Answers0