0
Good evening, I’m a beginner in mysql and I came up with the following question. When I make a transaction like this
START TRANSACTION ;
INSERT INTO PESSOA2(IDPESSOA,NOME) VALUES(NULL,'PEDRO2');
INSERT INTO DEPENDENTES(IDDEP,NOME,IDPESSOA) VALUES(NULL,'CAROL',543);
INSERT INTO DEPENDENTES(IDDEP,NOME,IDPESSOA) VALUES(NULL,'CAROL',1);
COMMIT;
is a test transaction, nothing specific ....
I put to give error in the second line purposely... but when the error happens, it does not insert anything in the dependent table (even the second Insert in the table is correct) ,but still inserts in the personal table2, why? I’m doing something wrong?! It wasn’t all or nothing?!
Thanks for your help
Good evening Ricardo, thank you for your attention. So, I’m very confused about this... if I do the following transaction in a single table, when finding the error, regardless if you have any correct line, it does not insert... Here comes the doubt, when the Insert is in a single table, to find error does not insert even containing other lines that are correct?!
START TRANSACTION ;
INSERT INTO DEPENDENT VALUES(NULL,'PEDRO',213); INSERT INTO TELEFONE VALUES (NULL,'CARLOS',1); COMMIT;
Continuing... Even without Handler, finding the error was not just meant to stop there?!
I had never seen Handler, I went to test the code you sent this giving error... "DECLARE IS NOT VALID AT THIS POSITION ..." Can you help me? Thank you very much!
Can you help me with the syntax Ricardo?! already researched on, and keeps up the error... Thank you!
– Pedro Fernandes
I made the edition as you asked Ricardo, thank you for your attention, I await your reply
– Pedro Fernandes
now got better :) I added more information in the reply
– Ricardo Pontual
Thanks Ricardo for the help ! I managed to understand and perform, I saw some other examples that also gave me a light, thanks for the patience and attention ! Big hug
– Pedro Fernandes