0
UPDATE Table1 a
SET a.Col2 = (
    SELECT SubStr(Trim(b.Col2),-10,10)
    FROM Table2 b
    WHERE (InStr(SubStr(Trim(b.Col2),-5,5),'/')=1 
        AND InStr(SubStr(Trim(b.Col2),1,(Length(Trim(b.Col2))-10)),'/')=0 
        AND SubStr(b.Col1,1,2)='01'
        AND b.Col3 != 000103))
WHERE SubStr(b.Col1,-8,8)=SubStr(a.Col1,1,8)
    AND a.Col3 = 1;

命令行错误:9 列:14 错误报告:SQL 错误:ORA-00904:“B”。“Col1”:无效标识符 00904。00000 -“%s:无效标识符”

第 9 行是WHERE SubStr(b.Col1,-8,8)=SubStr(a.Col1,1,8)

4

1 回答 1

1

您可以尝试MERGE

MERGE INTO Table1 a
USING (
    SELECT *
    FROM Table2 b
    WHERE (InStr(SubStr(Trim(b.Col2),-5,5),'/')=1 
        AND InStr(SubStr(Trim(b.Col2),1,(Length(Trim(b.Col2))-10)),'/')=0 
        AND SubStr(b.Col1,1,2)='01'
        AND b.Col3 != 000103)
) c ON (SubStr(c.Col1,-8,8)=SubStr(a.Col1,1,8))
WHEN MATCHED THEN
    UPDATE SET a.Col2 = SubStr(Trim(c.Col2),-10,10)
        WHERE a.Col3 = 1;
于 2013-06-03T21:44:25.637 回答