Pascal Data Objects

procedure TPDO.beginTransaction;

Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO object instance are not committed until you end the transaction by calling TPDO.commit. Calling TPDO.rollback will roll back all changes to the database and return the connection to autocommit mode.

Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit COMMIT will prevent you from rolling back any other changes within the transaction boundary.

    try
        db.beginTransaction;
        db.execute_now(
            'UPDATE league_setup ' + 
            'SET baseline_flags = 127 ' + 
            'WHERE season = 2003');
        if (db.errorInfo.error_code > 0) then raise exception.create ('Bad Update');
        db.execute_now(
            'DELETE FROM seasonal_configuration ' +
            'WHERE season = 2003 and config_name LIKE ''stage%''');
        if (db.errorInfo.error_code > 0) then raise exception.create ('Bad Delete');
        db.commit;
    except
        db.rollBack;
    end;