我想大規模更新Paytotaxid
。我現在用的是Case
聲明..的如下圖所示如何擺脫錯誤「缺少表達」,而使用UPDATE CASE
UPDATE Persons
SET Paytotaxid = CASE Paytotaxid
WHEN = ''
THEN ''
ELSE 'XXXX' || RIGHT(TaxID,4)
END;
但我不斷收到錯誤缺少表達式。
現狀
PERSONID LASTNAME FIRSTNAME ADDRESS CITY PAYTOTAXID TAXID
11 Tom B. Erichsen Skagen 21 Stavanger Norway 123-57-2988 123-57-2988
22 Joe B. Erichsen Skagen 21 Stavanger minneapolis 123-57-3338 123-57-3338
33 Mary B. Erichsen Skagen 21 Stavanger Norway 123-57-4444 123-57-4444
44 Jaya B. Erichsen Skagen 21 Stavanger Norway
預期結果
PERSONID LASTNAME FIRSTNAME ADDRESS CITY PAYTOTAXID TAXID
11 Tom B. Erichsen Skagen 21 Stavanger Norway XXXXX2988 123-57-2988
22 Joe B. Erichsen Skagen 21 Stavanger minneapolis XXXXX3338 123-57-3338
33 Mary B. Erichsen Skagen 21 Stavanger Norway XXXXX4444 123-57-4444
44 Jaya B. Erichsen Skagen 21 Stavanger Norway
取出'='後 – DBug
我得到一個錯誤說 - ORA-00904:「RIGHT」:無效的標識符。是「正確」在oracle中無效? – user5704279
不,在Oracle(11gR2)中,Right不是有效的函數。你將不得不使用'SUBSTR(TaxId,LENGTH(TaxID)-4)' – DBug