Page 1 of 1

How to get partial parsing of SQL

Posted: 31.03.2008, 20:26
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

Posted: 01.04.2008, 14:37
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

Posted: 02.04.2008, 19:27
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

Posted: 02.04.2008, 20:26
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