SELECT ru.roleuser ,
opr.emplid ,
ru.rolename ,
ru.dynamic_sw ,
AU.AUDIT_OPRID ,
TO_CHAR(au.audit_stamp , 'YYYY-MM-DD HH.MI.SS')
FROM psoprdefn opr ,
psroleuser ru
LEFT OUTER JOIN HRSECADM.wb_audit_psroleuser AU
ON (au.roleuser = ru.roleuser
AND au.rolename = ru.rolename )
WHERE opr.oprid = ru.roleuser
AND (au.audit_stamp =
(SELECT MAX(au_ed.audit_stamp)
FROM HRSECADM.wb_audit_psroleuser au_ed
WHERE ru.roleuser = au_ed.roleuser
AND au_ed.rolename = ru.rolename
)
OR au.audit_stamp IS NULL) ;
获取错误:
ORA-01779: cannot modify a column which maps to a non key-preserved table.
我在上面的sql.if中面临上述问题我希望在上面的sql上更新数据我们面临一些sql错误。
错误位置:30返回:1779 - ORA-01779: cannot modify a column which maps to a non key-preserved table
SQL stmt失败:UPDATE PS_ROLUSR_AUD_VW_W SET OPRID =:1 WHERE OPRID =:2 AND EMPLID =:3
答案 0 :(得分:0)
您正在尝试访问PeopleSoft DataDictionary表以执行某些更新。那太热了!但是,您的SQL是两个表之间的连接。在Oracle中,通常允许更新连接,但有几个条件:
答案 1 :(得分:0)
确保用于加入的表格应该有一些密钥。
DROP TABLE x;
CREATE TABLE x
(
child NUMBER (1), -- primary key,
parent NUMBER (3),
notes VARCHAR2 (10),
notes1 VARCHAR2 (10),
notes2 VARCHAR2 (10),
notes3 VARCHAR2 (10),
notes4 VARCHAR2 (10)
);
CREATE TABLE y (child NUMBER (1) PRIMARY KEY);
INSERT INTO x
VALUES (1,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (2,
1,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (3,
1,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (4,
2,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (5,
1,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (5,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (6,
5,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (7,
5,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO x
VALUES (8,
6,
NULL,
NULL,
NULL,
NULL,
NULL);
INSERT INTO y
VALUES (1);
INSERT INTO y
VALUES (2);
INSERT INTO y
VALUES (5);
INSERT INTO y
VALUES (6);
SELECT * FROM x;
UPDATE (SELECT x.child,
x.parent,
x.notes,
x.notes1,
x.notes2,
x.notes3,
x.notes4
FROM x INNER JOIN y ON x.parent = y.child
WHERE TRIM (notes) IS NULL
AND TRIM (notes1) IS NULL
AND TRIM (notes2) IS NULL
AND TRIM (notes3) IS NULL
AND TRIM (notes4) IS NULL) z
SET z.notes1 = 'notes1',
z.notes2 = 'notes2',
z.notes3 = 'notes3',
z.notes4 = 'notes4';