In the user1.btable
table, user1.btable
a unique constraint for 4 fields: c, d, e, f
.
Request
update (select a.bid a$bid, b.bid b$bid from user1.atable a join user1.btable b on ac = bc and ad = bd and ae = be and bf = 0) set a$bid = b$bid;
gives an error message
ORA-01779: cannot change column, cat. Displays non key-preserved table
Why? After all, usually this error occurs for the following reason
Oraklu need to uniquely identify the record that needs to be changed. And for this, the subquery must use all the columns in a unique key. In addition, in the first case, you may have a problem with the fact that several rows from Balitsa B will be selected for one record from Table A and then it will not be clear to Oracle which of records B to take the bid - Mike
And if user1.atable
add the f
field to the user1.atable
table, and change the join condition to
on ac = bc and ad = bd and ae = be and bf = af
The request does not give an error.
Issuing SELECT * FROM V$VERSION
Oracle Database 11g Enterprise Edition 11.2.0.1.0 - 64bit Production
PL / SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
update user1.atable a set bid=(select nvl(max(b.bid),a.bid) from user1.btable b where ac = bc and ad = bd and ae = be and bf = 0)
- Mike