【问题标题】:ORA-00933: SQL command not properly ended ORA-06512:ORA-00933: SQL 命令未正确结束 ORA-06512:
【发布时间】:2014-06-22 00:32:24
【问题描述】:

这有什么问题, 我收到此错误

OLE DB provider "OraOLEDB.Oracle" for linked server "hades" returned message "ORA-00933: SQL command not properly ended
ORA-06512: at "SAAP.EDI", line 1416".
OLE DB provider "OraOLEDB.Oracle" for linked server "hades" returned message "ORA-00933: SQL command not properly ended
ORA-06512: at "SAAP.EDI", line 1416".
Msg 7320, Level 16, State 2, Line 2
Cannot execute the query "select * from table(edi.ftCustomerCatalog('010','145','000164'))" against OLE DB provider "OraOLEDB.Oracle" for linked server "hades". 

代码:

function ftCustomerCatalog(comno varchar2,cpls varchar2, cuno varchar2) return tblCustomerCatalog pipelined 
is
  c sys_refCursor;
  r recCustomerCatalog;
  sq varchar2(3000);
begin
  sq:='select  
        a.comno
        ,a.t$cpls
        ,coalesce(a.t$cuno,b.t$cuno) as t$cuno
    ,a.t$cpgs,a.t$item
        ,a.t$Upcd
        ,a.t$dsca
        ,a.t$wght
        ,a.t$ship
      ,coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt) as T$STDT
      ,coalesce(b.t$tdat,c.t$tdat,d.t$tdat,e.t$tdat,f.t$tdat) as t$tdat
      ,coalesce(b.t$qanp,c.t$qanp,d.t$qanp,e.t$qanp,f.t$qanp) as t$qanp
      ,a.t$pric
      ,coalesce(b.t$disc,c.t$disc,d.t$disc,e.t$disc,f.t$disc) as t$disc
      ,coalesce(b.source,c.source,d.source,e.source,f.source) as Source 
      from  table(edi.ftAllPlCatalogs(:comno,cpls)) where t$cuno=:cuno a
        left join table(edi.ft30ciDiscounts(:comno,:cpls,:cuno)) b on a.t$item=b.T$item and a.t$cuno=b.t$cuno
        Left Join table(edi.ft31CPGDiscounts(:comno,:cpls,:cuno))  c on a.t$cpgs=c.t$cpgs
        left Join table(edi.ft31Cdiscounts  (:comno,:cpls,:cuno)) d on d.t$cpgs is null
        left join table(edi.ft33plpgDiscounts(:comno,:cpls)) e on d.t$disc is null and a.t$cpgs=e.t$cpgs
        left join table(edi.ft33PlDiscount(:comno,:cpls)) f on e.t$disc is null 
      Order by A.T$CPGS, a.t$item;';
  Open c for SQ using
      comno,cpls,cuno
      ,comno,cpls,cuno
      ,comno,cpls,cuno
      ,comno,cpls,cuno
      ,comno,cpls
      ,comno,cpls;
   LOOP
    fetch c into r;
    exit when c%notfound;
    pipe row(r);
  END LOOP;
  close c;
end;

【问题讨论】:

  • 您收到了来自 oracle 的默认错误消息。在很长的查询中某处存在语法错误。我建议重新开始并采取婴儿步骤。写一行并运行它。然后再添加一点并运行它。每次遇到错误时,您都会知道它是由您添加的最后一个内容引起的。

标签: sql oracle sql-server-2008 oracle11g


【解决方案1】:

我不认为语法

t$stdt=coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt)

在 Oracle 中有效。

假设意思是为表达式提供别名,我相信 Oracle 的等价物是:

coalesce(b.t$stdt,c.t$stdt,d.t$stdt,e.t$stdt,f.t$stdt) AS stdt

(AS 关键字开始可选)

【讨论】:

  • 绝对正确..谢谢,使用“AS”修改了代码,但现在我得到链接服务器“hades”的此 OLE DB 提供程序“OraOLEDB.Oracle”返回消息“ORA-00933:SQL 命令不正确结束 ORA-06512:在“SAAP.EDI”,第 1416 行。链接服务器“hades”的 OLE DB 提供程序“OraOLEDB.Oracle”返回消息“ORA-00933:SQL 命令未正确结束 ORA-06512:在“SAAP.EDI”,第 1416 行”。消息 7320,级别 16,状态 2,第 2 行无法针对链接的 OLE DB 提供程序“OraOLEDB.Oracle”执行查询“select * from table(edi.ftCustomerCatalog('010','145','000164'))”服务器“哈迪斯”。
  • @TonyP 您不需要在查询字符串中使用分号 (;)
  • @dave,我有分号和没有分号,没有区别。
  • @TonyP WHERE 子句应该跟在 JOIN 子句之后。
猜你喜欢
  • 2010-09-09
  • 2010-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多