【问题标题】:Select on field Date in OpenEdge在 OpenEdge 中选择字段日期
【发布时间】:2020-11-23 08:35:47
【问题描述】:

我正在尝试使用 Microsoft SQL Server Management Studio (select * from openquery ([PROALPHA], 'select Date from PAVAR.PUB.UVT_DatesOfVersionsBOPos') 在表 UVT_DatesOfVersionsBOPos 中的“日期”字段上进行选择

很遗憾,我收到以下错误消息:

The OLE DB provider "MSDASQL" for the connection server "PROALPHA" has the message "[DataDirect] [ODBC Progress OpenEdge Wire Protocol driver] [OPENEDGE] Syntax error in SQL statement at or about" Date from PAVAR.PUB.UVT_DatesOfVersionsB "( 10713) ".

Msg 7321, Level 16, State 2, Line 1

Failed to prepare the select date from PAVAR.PUB.UVT_DatesOfVersionsBOPos query to run for the OLE DB provider "MSDASQL" for the linked server "PROALPHA".

我假设 SQL 将 Date 字段解释为 Date 函数,因此会显示错误。
你们有谁知道正确的语法,所以我可以得到这个字段?

【问题讨论】:

    标签: sql openedge progress-db


    【解决方案1】:

    语法错误是因为 DATE 是 OpenEdge SQL 中的保留字。只有在使用双引号分隔关键字时,才能在 SQL 语句中使用关键字作为标识符。

    示例 1:如您所述,这会产生语法错误

    SQLExplorer>select date from pub.cust1;
    === SQL Exception 1 ===
    SQLState=HY000
    ErrorCode=-210056
    [DataDirect][OpenEdge JDBC Driver][OpenEdge] Syntax error in SQL statement at or about "date from pub.cust1" (10713)
    

    示例 2:这适用于我们用双引号分隔保留字

    SQLExplorer>select "date" from pub.cust1;
    date
    ----------
    

    文档链接:https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dmsrf/openedge-sql-reserved-words.html

    【讨论】:

    • 。 .或者更好的建议是避免使用关键字和保留字作为标识符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 2015-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-26
    相关资源
    最近更新 更多