Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2006-04

IBConnection and transactions

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

I have a problem that I do not understand.

the following doesn't work with firebird:

  Fconnection.ExecuteDirect('create table FPDEV (id INT)');
  Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)');

But the following does:

  Fconnection.ExecuteDirect('create table FPDEV (id INT)');
  FConnection.Transaction.commitretaining;
  Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)');

But both statements are executed within the same transaction?

What's going wrong? Can someone help me with this?

Joost.

Reply by email

Treeve Jelbert
to Michael Van Canneyt: No they are not. CommitRetaining is like Commit; Starttransaction; only keeps the…
Michael Van Canneyt wrote 23 lines
On Sun, 30 Apr 2006, Joost van der Sluis wrote: > I have a problem that I do not understand. > > the following doesn't work with firebird: > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > But the following does: > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > FConnection.Transaction.commitretaining; > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > But both statements are executed within the same transaction? No they are not. CommitRetaining is like Commit; Starttransaction; only keeps the resources of the current transaction. In all the years I worked with interbase/firebird, I've learned to explicitly commit after each DDL statement.

it is not allowed to mix DDL and DML statements in the same transaction when using firebird

Show quoted text 7 lines
Michael. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel
Regards, Treeve

Reply by email

Michael Van Canneyt
to Joost van der Sluis: I have a problem that I do not understand. the following doesn't work with firebird:…
Joost van der Sluis wrote 14 lines
I have a problem that I do not understand. the following doesn't work with firebird: Fconnection.ExecuteDirect('create table FPDEV (id INT)'); Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); But the following does: Fconnection.ExecuteDirect('create table FPDEV (id INT)'); FConnection.Transaction.commitretaining; Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); But both statements are executed within the same transaction?
No they are not. CommitRetaining is like
Commit;
Starttransaction;
only keeps the resources of the current transaction.

In all the years I worked with interbase/firebird, I've learned to explicitly commit after each DDL statement.

Michael.

Reply by email

Joost van der Sluis
to Michael Van Canneyt
Michael Van Canneyt wrote 23 lines
On Sun, 30 Apr 2006, Joost van der Sluis wrote: > I have a problem that I do not understand. > > the following doesn't work with firebird: > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > But the following does: > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > FConnection.Transaction.commitretaining; > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > But both statements are executed within the same transaction? No they are not. CommitRetaining is like Commit; Starttransaction; only keeps the resources of the current transaction. In all the years I worked with interbase/firebird, I've learned to explicitly commit after each DDL statement.

Ok, that explains it. But in fact that's a bug in Interbase/Firebird imho...

Thanks for the info.

Joost.

Reply by email

Michael Van Canneyt
to Joost van der Sluis
Joost van der Sluis wrote 27 lines
On Sun, 2006-04-30 at 20:09 +0200, Michael Van Canneyt wrote: > On Sun, 30 Apr 2006, Joost van der Sluis wrote: > > I have a problem that I do not understand. > > > > the following doesn't work with firebird: > > > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > > > But the following does: > > > > Fconnection.ExecuteDirect('create table FPDEV (id INT)'); > > FConnection.Transaction.commitretaining; > > Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); > > > > But both statements are executed within the same transaction? > > No they are not. CommitRetaining is like > Commit; > Starttransaction; > only keeps the resources of the current transaction. > > In all the years I worked with interbase/firebird, > I've learned to explicitly commit after each DDL statement. Ok, that explains it. But in fact that's a bug in Interbase/Firebird imho...

It is. They know about it, too.

Michael.

Reply by email

Bogusław Brandys
to Michael Van Canneyt
Michael Van Canneyt wrote 32 lines
On Sun, 30 Apr 2006, Joost van der Sluis wrote: > On Sun, 2006-04-30 at 20:09 +0200, Michael Van Canneyt wrote: >> On Sun, 30 Apr 2006, Joost van der Sluis wrote: >>> I have a problem that I do not understand. >>> >>> the following doesn't work with firebird: >>> >>> Fconnection.ExecuteDirect('create table FPDEV (id INT)'); >>> Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); >>> >>> But the following does: >>> >>> Fconnection.ExecuteDirect('create table FPDEV (id INT)'); >>> FConnection.Transaction.commitretaining; >>> Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); >>> >>> But both statements are executed within the same transaction? >> No they are not. CommitRetaining is like >> Commit; >> Starttransaction; >> only keeps the resources of the current transaction. >> >> In all the years I worked with interbase/firebird, >> I've learned to explicitly commit after each DDL statement. > Ok, that explains it. But in fact that's a bug in Interbase/Firebird > imho... It is. They know about it, too. Michael.

Well,sort of, but how you can insert data into table which is not created yet ?

Regards
Boguslaw

Reply by email

Michael Van Canneyt
to Bogusław Brandys
[UTF-8] Bogusław Brandys wrote 36 lines
Michael Van Canneyt wrote: > > On Sun, 30 Apr 2006, Joost van der Sluis wrote: > >> On Sun, 2006-04-30 at 20:09 +0200, Michael Van Canneyt wrote: >>> On Sun, 30 Apr 2006, Joost van der Sluis wrote: >>>> I have a problem that I do not understand. >>>> >>>> the following doesn't work with firebird: >>>> >>>> Fconnection.ExecuteDirect('create table FPDEV (id INT)'); >>>> Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); >>>> >>>> But the following does: >>>> >>>> Fconnection.ExecuteDirect('create table FPDEV (id INT)'); >>>> FConnection.Transaction.commitretaining; >>>> Fconnection.ExecuteDirect('insert into FPDEV(id) values (1)'); >>>> >>>> But both statements are executed within the same transaction? >>> No they are not. CommitRetaining is like >>> Commit; >>> Starttransaction; >>> only keeps the resources of the current transaction. >>> >>> In all the years I worked with interbase/firebird, >>> I've learned to explicitly commit after each DDL statement. >> Ok, that explains it. But in fact that's a bug in Interbase/Firebird >> imho... > > It is. They know about it, too. > > Michael. Well,sort of, but how you can insert data into table which is not created yet ?

It is created.
The transaction is not yet committed, so the table is not visible outside the current transaction, but inside the transaction, it exists, so one would expect that inserts work...

Michael.

Reply by email