Simple example (PSEUDO CODE):
for (int i = 0; i < 100; i++) { START TRANSACTION; SELECT id, name FROM employees WHERE id = i; IF (someFunction(id)) { ROLLBACK; CONTINUE; // GO TO NEXT EXECUTION OF FOR LOOP } UPDATE company SET good = good + 1; COMMIT; }
Can I use in this example COMMIT (so I'm gonna have two COMMIT in my script) instead of ROLLBACK?
Does it make any difference to the database if I use COMMIT instead of ROLLBACK after select?
Is there any difference between MySQL and PostgreSQL here?
break;
stops/exits a loop. You're looking forcontinue;
, I think.