I have this Table:
TableAB
{
IDTableA;
IDTableB;
}
I have one row in the table, (1,2). Now I want to insert some others values, and I want to do it in a transaction. I use this:
begin
insert into TableAB (IDTAbleA, IDTAbleB) VALUES(1,2);
insert into TableAB (IDTAbleA, IDTAbleB) VALUES(1,3);
insert into TableAB (IDTAbleA, IDTAbleB) VALUES(1,3);
commit
I get an error of integrity in the first insert, but the second and third insert, insert the values in the table.
How I am using a transaction and fails the first one, why does it insert the other two rows? I thought inside a transaction, if somethings fails, all is aborted. Then in this case, which is the difference to use the transaction and don't use it?
Thanks.