oracle “ORA-01747:无效的 user.table.column、table.column 或列规范”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5265397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:01:11  来源:igfitidea点击:

"ORA-01747: invalid user.table.column, table.column, or column specification"

oraclelinked-server

提问by Ashar Syed

I am trying to execute this query against Oracle linked server, and getting the following error, which I know that my query is malformed, but I couldn't figure out where and how.

我试图对 Oracle 链接服务器执行此查询,并收到以下错误,我知道我的查询格式错误,但我无法弄清楚在哪里以及如何。

DECLARE @CREDIT_CUST_SQL NVARCHAR(1000) = NULL;
SET @CREDIT_CUST_SQL = 'SELECT 
                           cu.[ST_CD]
                          ,cu.[SRT_CD]
                          ,cu.[TITLE]
                          ,cu.[FNAME]
                          ,cu.[INIT]
                          ,cu.[LNAME]
                          ,cu.[ADDR1]
                          ,cu.[ADDR2]
                          ,cu.[CITY]
                          ,cu.[COUNTRY]
                          ,cu.[ZIP_CD]
                          ,cu.[HOME_PHONE]
                          ,cu.[BUS_PHONE]
                          ,cu.[EXT]
                        FROM [AR].[CUST] cu, 
                             [CUSTOM].[CUST_OTHER] co, 
                             [AR].[CUST_CR] cc
                        WHERE cu.CUST_CD = co.CUST_CD 
                            AND cu.CUST_CD = cc.CUST_CD
                            AND cu.DOB IS NOT NULL'



EXECUTE (@CREDIT_CUST_SQL) AT LIVE_BD;

And I get this error,

我得到这个错误,

"ORA-01747: invalid user.table.column, table.column, or column specification"

“ORA-01747:无效的 user.table.column、table.column 或列规范”

Any idea why is happening. Thanks.

知道为什么会发生。谢谢。

回答by jachguate

Your code looks like SQL Server

您的代码看起来像 SQL Server

Do not use the brackets ([]) to quote the column names, just leave it as is for the capitalized valid identifiers or use the (sql standard) double quotes to the non valid identifiers or non capitalized ones.

不要使用方括号 ( []) 来引用列名,对于大写的有效标识符,请保持原样,或者对无效的标识符或非大写的标识符使用(sql 标准)双引号。

Like this:

像这样:

SELECT 
                       cu.ST_CD
                      ,cu.SRT_CD
                      ,cu.TITLE
                      ,cu.FNAME
                      ,cu.INIT
                      ,cu.LNAME
                      ,cu.ADDR1
                      ,cu.ADDR2
                      ,cu.CITY
                      ,cu.COUNTRY
                      ,cu.ZIP_CD
                      ,cu.HOME_PHONE
                      ,cu.BUS_PHONE
                      ,cu.EXT
                    FROM AR.CUST cu, 
                         CUSTOM.CUST_OTHER co, 
                         AR.CUST_CR cc
                    WHERE cu.CUST_CD = co.CUST_CD 
                        AND cu.CUST_CD = cc.CUST_CD
                        AND cu.DOB IS NOT NULL