我原来的更新语句在 Sybase 中仍然运行良好(见下文),但我们正在迁移到 Oracle 11g,我必须将此更新语句转换为 Oracle 更新。我尝试了这么多版本并不断出错,我想我还没有了解 Oracle Update 语句的工作原理。任何人都可以帮忙吗?
我原来好的更新语句(在 Sybase 中):
UPDATE Valid
SET A.status = 'X',
A.reason = 'Missing'
FROM Valid A, Valid B
WHERE A.id_number = B.id_number
AND A.session_id = 69
AND A.userid = 'BS'
AND A.status = 'A'
AND isnull(B.street1, ' ') = ' '
以下是我的 Oracle 版本,无论我做什么都无法正常工作:
MERGE
INTO um_valid Target
USING (select * from um_valid) SOURCE
ON (t1.id_number = t2.id_number)
WHEN MATCHED THEN
UPDATE
SET status = 'X',
reason = 'Missing (street 1)'
WHERE Target.session_id = 69
AND Target.userid = 'BS'
AND Target.status = 'A'
AND NVL(SOURCE.street1, ' ') = ' ')
我得到的错误:
ORA-00933: SQL command not properly ended