用于解析SQL语句的库 [英] Library to parse SQL statements

查看:56
本文介绍了用于解析SQL语句的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够解析一个任意的SQL SELECT语句并检索各个组成部分(列,关系,JOIN条件,WHERE条件,ORDER BY列),最好使用Delphi.谷歌快速搜索显示了几种不同的免费软件产品,但尚不清楚它们是否完整和/或正在积极开发中.

I would like to be able to parse an arbitrary SQL SELECT statement and retrieve the various component parts (columns, relations, JOIN conditions, WHERE conditions, ORDER BY columns), ideally using Delphi. A quick google search shows several different freeware products, but it's not clear if they are complete and/or under active development.

我现在只需要提取一系列VIEW定义中使用的关系列表,以确保在尝试创建视图之前存在所需的视图或表.因此,例如,对于以下语句:

My immediate need to just to extract the list of relations used in a series of VIEW definitions in order ensure that required views or tables exist before I try to CREATE the view. So, for instance, for the statement:

SELECT PersonID, LastName, OrderID 
FROM People P INNER JOIN Orders O ON P.PersonID = O.PersonID

我需要取回值"People"和"Orders".(显然,这是一个简单的示例.我希望能够处理更复杂的情况,例如,单词"FROM"可能作为表达式的一部分出现在列列表中.)

I need to get back the values "People" and "Orders". (Obviously, this is a simple example. I want to be able to handle more complex cases where, for instance, the word "FROM" might appear in the column list as part of an expression).

我正在尝试在允许使用从DLL导出的STDCALL函数的数据库中提供此服务,因此理想情况下,可以从Delphi或C中调用任何候选库.

I'm trying to provide this service in a database that allows use of STDCALL functions exported from DLLs, so ideally any candidate library would be callable from Delphi or C.

推荐答案

看看 Gold Parser.它提供了Delphi版本,并且在下载页面上提供了SQL语法.

Take a look at Gold Parser. It's got a Delphi version available, and SQL grammar on the download page.

这篇关于用于解析SQL语句的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆