Board index » delphi » Parsering SQL statement.

Parsering SQL statement.

Hi all.

I want to parse SQL statement and add additional restrictions in it
WHERE clause.

For example: there is following query
  SELECT * FROM xTable WHERE xCol = 5
I want to add restriction at runtime by another column that yCol > 10,
that result will be like this
  SELECT * FROM xTable WHERE (xCol = 5) AND (yCol > 10)

Does anybody know any parser of SQL statements or full syntax diagram of

SQL SELECT statement (in detail with expression)?
I talk about LOCAL SQL of BDE v.4.51.

Thank you in advance.

Dimitar Angelov
EDA Ltd.


Re:Parsering SQL statement.


I doubt that there is any ready-made solution for this.
I developed a class that collects fields and bind variables and stores each
part of where-, group and having-clause in a string array. Then the class
provides functions that assemble the complete statement. This sounds a bit
complicated but it has proven to be handled easily.
I think you will also have to go that way.


Joachim Meyer (
BASYS EDV-Systeme GmbH

Re:Parsering SQL statement.

Do a search on AdHocery or go to Nevrona Designs website. They have a
whole slew of components that can do lots of things, one of which is the
ability to generate SQL Statements. It's pretty easy to then manipulate
the where clause. Might be worth a look for you.

Other Threads