TMyQuery Addwhere with a LIMIT sentence

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
a.alekizoglou
Posts: 32
Joined: Fri 22 Sep 2006 08:32

TMyQuery Addwhere with a LIMIT sentence

Post by a.alekizoglou » Fri 22 Sep 2006 08:38

Hi,

i am using MyDAC 3.55.0.26 with Delphi 7. I utilize TMyQuery's Addwhere procedure to support runtime queries. The proplem is that when i have a sentence like the above:

SELECT *
FROM conctact
WHERE (contact.bActive = TRUE)
LIMIT 1000

and add a new where clause with Addwhere like the one:

AddWhere('(strSurName = 'MATOWN')')

the SQL sentence goes like this

SELECT *
FROM conctact
WHERE ((contact.bActive = TRUE)
LIMIT 1000) AND (strSurName = 'MATOWN')

which of course is wrong.

Can anyone tell if the problem exists, and if so, is there any shortcut for this, or should we wait for a new release.

Regards,

Athanasios Alekizoglou

a.alekizoglou
Posts: 32
Joined: Fri 22 Sep 2006 08:32

Post by a.alekizoglou » Fri 22 Sep 2006 09:01

OK,

it seems the problem is that i have a macro for adding the LIMIT xxx sentence where the macro is the entire sentence:

SELECT *
FROM conctact
WHERE (contact.bActive = TRUE)
&customlimit

So if i change this to

SELECT *
FROM conctact
WHERE (contact.bActive = TRUE)
LIMIT &customlimit

then the AddWhere works fine.

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

Post by Antaeus » Fri 22 Sep 2006 13:34

You have determined the reason of the problem correctly. This happens because AddWhere method does not analyze macros contents.

Post Reply