Multiple SQL statements possible ?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Nukster
Posts: 2
Joined: Sat 04 Aug 2007 18:07

Multiple SQL statements possible ?

Post by Nukster » Sat 04 Aug 2007 18:14

Hi there :)

I have a question. Maybe it's a dumb one but I'm just not sure if it's possible without causing trouble...

Is is possible to use multiple statements for the SQLUpdate property in TMyQuery ?

Somethin like this:

MyQuery.SQLUpdate.Clear;
MyQuery.SQLUpdate.Add('UPDATE terminals SET terminal_machineid = :terminal_machineid, terminal_requiresnewregistration = 0 WHERE terminal_id = :OLD_terminal_id;');
MyQuery.SQLUpdate.Add('UPDATE terminals SET terminal_requiresnewregistration = 1 WHERE (terminal_machineid = :terminal_machineid) AND (terminal_id :OLD_terminal_id);');

It seems to work flawlessly on a MySQL server 5.0.41. I'm just not sure if there are any side effects which I should be aware of...

Thx in advance

Bernd

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 06 Aug 2007 09:58

Yes it is possible. But you should set TMyQuery.Options.StrictUpdate to
False.

ben
Posts: 119
Joined: Wed 17 Nov 2004 19:48

Post by ben » Sat 11 Aug 2007 09:22

i used to execute multiple UPDATE or INSERT queries without StrictUpdate and have no problems. why?

Nukster
Posts: 2
Joined: Sat 04 Aug 2007 18:07

Post by Nukster » Sat 11 Aug 2007 22:04

ben wrote:i used to execute multiple UPDATE or INSERT queries without StrictUpdate and have no problems. why?
If StrictUpdate is on and the last insert/update statement affects more than ONE row (RowsAffected > 1) you will get an exception.

Setting StrictUpdate=False disables this "more-than-one-row-affected" check.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 13 Aug 2007 07:03

You are right, but I should add that StrictUpdate mode checks whether the affected rows count equals to one. You have missed the case when the affected rows count is less than one.

Post Reply