Understanding Why Using Commit or Rollback In Scripts Is Strongly Discouraged

By design you cannot commit or rollback the transaction from within your scripts. Any changes made by your scripts get committed or rolled-back along with the rest of the current transaction.

If your script code were allowed to call commit() or rollback(), this would affect all changes pending in the current transaction, not only those performed by your script and could lead to data inconsistencies.