我正在尝试使用以下语句创建父/子关系:
UPDATE (SELECT F2.FOLDERRSN NEW, F1.PARENTRSN OLD
FROM AMANDA.FOLDER F1
INNER JOIN AMANDA.FOLDER F2 ON F1.PARENTRSN = F2.CONVERSIONRSN
WHERE F1.FOLDERRSN BETWEEN 213010 AND 217773
AND F2.FOLDERTYPE = 'ESC') T
SET T.OLD = T.NEW
select语句有效并显示我期望的两个值,但是与更新一起我收到以下错误:
SQL错误:ORA-01779:无法修改映射到非密钥保留表的列
任何人都可以通过其他方式帮助我实现这一目标吗?
答案 0 :(得分:0)
尝试:
UPDATE AMANDA.FOLDER F1
SET F1.PARENTRSN = (
SELECT F2.FOLDERRSN
FROM AMANDA.FOLDER F2
WHERE F1.PARENTRSN = F2.CONVERSIONRSN
AND F2.FOLDERTYPE = 'ESC'
)
WHERE F1.FOLDERRSN BETWEEN 213010 AND 217773
但很可能上述查询会抛出错误:
ORA-01427: single-row subquery returns more than one row
,
因为您的查询提供ORA-01779