SQL 语句的所有可能的第一个单词是什么?

我正在构建一个用户界面,以便能够在 SQL Server 数据库上执行 SQL 语句,与 SQL Server 2008 R2 兼容.我需要能够确定每个语句是否可能返回一个数据集,或者它是否只需要执行.在 Delphi 中,TADOQuery 由数据集的 Open/Close 或仅用于执行的 ExecSQL 组成.我需要根据 SQL 语句的第一个单词自动确定使用哪个.

I'm building a user interface to be able to execute SQL statements on a SQL Server database, compatibility at SQL Server 2008 R2. I need to be able to determine whether each statement could possibly return a dataset, or if it just needs to be executed. In Delp the TADOQuery consists of either Open / Close for a dataset, or ExecSQL just to execute. I need to automatically determine which one to use based on the first word(s) of the SQL statement.

如何根据语句中的第一个单词确定应该调用哪个方法?我需要知道每个可能的单词,以及基于每个单词的方法.

How can I determine which method I should call based on the first word(s) in the statement? I would need to know each possible word, and which method based on each word.

推荐答案

这在一般意义上是不可能的.例如,EXEC 存储过程名称可以返回结果集或不返回结果集,具体取决于 proc 的编写方式.仅从调用的语法无法知道是其中一个还是另一个.

That is not possible in the general sense. EXEC stored-procedure-name for example can eithers return a result set or not, depending on how the proc is written. There is no way to know if it's one or the other just from the syntax of the call.

相关文章