Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread sql rollback
Wed, Jul 12 2006 10:47 AMPermanent Link

Jerry Blumenthal
I'm not sure how to do a try-except-rollback with a series of SQL
statements.  Please tell me if the following is correct.  (Using D4 and
dbisam 2.12)

1. Put a tDBISAMdatabase onto the form and set its databasename to
'myDB' and its name to MainDB

2. Put a tdbisamquery onto the form and set its databaseName to 'myDB'
and its name to Q1

3. code as follows:
maindb.StartTransaction;
Q1.sql.clear;
q1.sql.add('ALTER TABLE "table1.dat" ADD FaxPhone char(14)');
q1.execsql;
maindb.commit;
except
  maindb.rollback;
  end;

Is this correct?

Jerry
Wed, Jul 12 2006 1:20 PMPermanent Link

Bernd Kuhlmann
Jerry,
> I'm not sure how to do a try-except-rollback with a series of SQL
> statements.  Please tell me if the following is correct.  (Using D4 and
> dbisam 2.12)
>
> 1. Put a tDBISAMdatabase onto the form and set its databasename to
> 'myDB' and its name to MainDB
>
> 2. Put a tdbisamquery onto the form and set its databaseName to 'myDB'
> and its name to Q1
>
> 3. code as follows:
> maindb.StartTransaction;
> Q1.sql.clear;
> q1.sql.add('ALTER TABLE "table1.dat" ADD FaxPhone char(14)');
> q1.execsql;
> maindb.commit;
> except
>    maindb.rollback;
>    end;
>
> Is this correct?
Yes if you use a select, update or delete statement.
No if you alter the table.

From the manual:

The following operations are not compatible with transactions and will cause
a transaction to commit if encountered during a transaction:

Backing Up and Restoring Databases
Verifying and Repairing Tables
Creating and Altering Tables
Adding and Deleting Indexes from a Table
Optimizing Tables
Upgrading Tables
Deleting Tables
Renaming Tables
Emptying Tables
Copying Tables


Bernd



Wed, Jul 12 2006 2:09 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Bernd,

<< No if you alter the table.

From the manual:

The following operations are not compatible with transactions and will
cause a transaction to commit if encountered during a transaction: >>

Quick note - under 2.x, the behavior was that the transaction was ignored
during those operations.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image