使用内部连接对Oracle错误进行语句更新

时间:2019-02-15 09:47:06

标签: oracle

我有一个在Sybase上运行良好的查询,但是在Oracle上运行它时出现以下错误

update table1
        set chk = b.chkakhir
    from table1 a
    inner join (select substr('0'||inkdwil,-2) wil,substr(chk,-4) site, wil||site chkakhir,wil||'0' chkdcust from table2) b
        on a.chk = b.site   
    where length(a.chk) = 4;

update table1
        set chk = b.chkakhir
    from table1 a
    inner join (select right('0'||inkdwil,2) wil,right(chk,4) site, wil||site chkakhir,wil||'0' chkdcust from table2) b
        on a.chk = b.site   
    where len(a.chk) = 4;

在oracle中查询工作

2 个答案:

答案 0 :(得分:0)

就Oracle而言,语法错误。应该看起来像这样:

UPDATE table1
   SET chk      =
          (SELECT b.chkakhir               --> instead of FROM, you have to use SELECT here
             FROM table1 a
                  INNER JOIN (SELECT SUBSTR ('0' || inkdwil, -2) wil,
                                     SUBSTR (chk, -4) site,
                                     wil || site chkakhir,
                                     wil || '0' chkdcust
                                FROM table2) b
                     ON a.chk = b.site
            WHERE LENGTH (a.chk) = 4);

答案 1 :(得分:0)

在oracle中查询工作

更新表1         设置chk =(选择chk     来自表1 a     内部联接(选择substr('0'|| inkdwil,-2)wil,substr(chk,-4)站点,substr('0'|| inkdwil,-2)|| substr(chk,-4)chkakhir, substr('0'|| inkdwil,-2)||'0'chkdcust from table2)b         在a.chk = b.site)上
    其中length(a.chk)= 4;