I would like to be able to parse an arbitrary SQL SELECT statement and retrieve various components (columns, relationships, JOIN conditions, WHERE conditions, ORDER BY columns), ideally using Delphi. A quick Google search reveals several different free products, but it is unclear whether they are complete and / or under active development.
I need to immediately extract the list of relationships used in the VIEW series of definitions to ensure that the required views or tables exist before I try to CREATE the view. So, for example, for approval:
SELECT PersonID, LastName, OrderID FROM People P INNER JOIN Orders O ON P.PersonID = O.PersonID
I need to return the values "People" and "Orders". (Obviously, this is a simple example. I want to be able to handle more complex cases where, for example, the word "FROM" can appear in the list of columns as part of an expression).
I'm trying to provide this service in a database that allows you to use the STDCALL functions exported from a DLL, so ideally any candidate library can be called from Delphi or C.
sql parsing delphi
Larry lustig
source share