How to get partial parsing of SQL

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
wahono
Junior Boarder
Junior Boarder
Posts: 32
Joined: 30.07.2007, 16:20
Location: Indonesia
Contact:

How to get partial parsing of SQL

Post by wahono »

Is it possible to get partial parsing of SQL in TZQuery? For example I set SQL with SELECT * FROM product WHERE code LIKE '001%', I want to get "WHERE code='001'" from TZQuery.

wahono
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi wahono,

There's a TZGenericStatementAnalyser class in the parsesql directory. It's able to split the different sections of a SQL statement (and do some more than that as well).
I can't immediately tell you how to split sections, but a few weeks ago there was a post which may be a little related : http://zeos.firmos.at/viewtopic.php?t=1736.

I hope you can find out something?
Feel free to post your solution in this thread.

Mark
Image
wahono
Junior Boarder
Junior Boarder
Posts: 32
Joined: 30.07.2007, 16:20
Location: Indonesia
Contact:

Post by wahono »

Thanks for your info, I will try it.

My purpose is I want to get list of grouping field value from filtering tdataset. When we make filter for TZ*Query, I want to show list of field value that can be choose by user, so the value for filtered field is value from original resultset only (but grouped/unique value).

Is in ZeosLib there is any function to show grouped field value from a field like Function UniqueFieldValue(afield: TField):TStringList or other function name;?

For example, the resultset of TZ*Query is :
field1
------
a1
a2
a1
a3
a5
a5

Than the result from Function UniqueFieldValue(afield: TField):TStringList is :
a1
a2
a3
a5

I think others field type can converted to string.

regards
wahono
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Such function doesn't exist AFAIK. Actually, I'm not convinced it should exist. It is quite a specialized function.

I've three idea's
- Parse the query and fire a separate query to get the distinct values.
- Loop through the resultset and get your list of distinct values
- Write some Descendent class from TZAbstractQuery and implement your specialized function.

Mark
Image
Post Reply