Unidac TUniscript with transaction

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Franky
Posts: 5
Joined: Fri 02 Sep 2016 20:20

Unidac TUniscript with transaction

Post by Franky » Fri 02 Sep 2016 20:28

Hi,

I have something strange, i hope someone knows whats causing this.

In my vcl application i use several ways to execute sql statements, one is with a TUniQuery, with seperate transaction, i execute a StartTransaction on the UniQuery and execute for example a alter table statement, the result is that the command does not have effect until i perform a commit.

Great, thats what i want.

But, on another form, when i do the same statement but using a TUniScript, also with seperate transaction and with Starttransaction before i Execute the UniScript, the statement immediatly has effect, without commiting the transaction.

Of course there is no commit in the script and autocommit is false on both the uniconnection and the uniscript components.

Does anyone have an idea why UniScript seems to autocommit?

Franky
Posts: 5
Joined: Fri 02 Sep 2016 20:20

Re: Unidac TUniscript with transaction

Post by Franky » Fri 02 Sep 2016 20:36

I forgot to mention the database is a Firebird db.

Franky
Posts: 5
Joined: Fri 02 Sep 2016 20:20

Re: Unidac TUniscript with transaction

Post by Franky » Sat 03 Sep 2016 10:17

Additional: a 'alter table add' statement has effect without commiting, a insert into statement however works as expected, the new record is only visible after performing a commit.

Franky
Posts: 5
Joined: Fri 02 Sep 2016 20:20

Re: Unidac TUniscript with transaction

Post by Franky » Sat 03 Sep 2016 18:44

Someone pointed me to this: viewtopic.php?t=21995
which explains it, i don't suppose i can turn off the autocommit of ddl statements so i'll have to replace unidac with something else.

It would have been better if the AutoCommit property was split in 2 properties, AutoCommitDDL and AutoCommitDML, this way i could have turned it off.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Unidac TUniscript with transaction

Post by ViktorV » Mon 05 Sep 2016 07:15

If you want us to implement the feature, please post it at our user voice forum: https://devart.uservoice.com/forums/104 ... 939-unidac. If the suggestion gets a lot of votes, we will consider the possibility to implement it.

Franky
Posts: 5
Joined: Fri 02 Sep 2016 20:20

Re: Unidac TUniscript with transaction

Post by Franky » Mon 05 Sep 2016 19:06

Well i'm not entirely sure anymore, i always assumed it would be possible to execute a ddl statement(like add a field to a table) in a transaction and then a dml statement (like put a value in the new created field) in the same transaction.

It seems that is a big mistake on my part, you can't do that, it's not possible in ibexpert either, and if i do the same with firedac, which does not commit the ddl statement automatically with Autocommit off, i get errors on the update statement because the field is not created yet.

So it all makes sense to me now that any ddl needs to commited when executing a script, so the way Unidac handles it is probably the good way.

Sorry for the misunderstanding, i'm not 100% used to work with transactiosn and it just confused me a bit.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Unidac TUniscript with transaction

Post by ViktorV » Tue 06 Sep 2016 07:05

Thank you for being interested in our products.
If you have any questions concerning our products, please don't hesitate to contact us - and we will try to help you resolve them.

Post Reply