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