【发布时间】:2013-11-24 22:13:32
【问题描述】:
我收到错误消息:当我运行以下语句时,无法在源表中获得一组稳定的行。
merge into table_1 c
using (select rep_nbr, T_nbr, SF from table_2) b
on (c.rep_id=b.rep_nbr)
when matched then
update set
c.T_ID =b.T_nbr,
c.SF=b.SF
when not matched then
insert(T_id, SF)
values(null, null);
当我把 distinct 放在 rep_nbr 之前
merge into table_1 c
using (select distinct rep_nbr,t_nbr,SF from table_2) b
on (c.rep_id=b.rep_nbr)
when matched then
update set
c.T_ID =b.T_nbr,
c.SF=b.SF
when not matched then
insert(T_id, SF)
values(null, null);
ORA-01400: 无法将 NULL 插入 c.rep_id。 我不想填充 c.rep_id,我只需要它们匹配,然后更新那些匹配的记录。
【问题讨论】:
-
那么是什么阻止您删除查询的最后一段?当不匹配时......
-
@mihai 我想没有必要拥有那部分。把它拿出来会有什么不同吗?
-
如果您只需要更新是的。在您的最后一个查询中,问题可能是在非空列中插入空值。
-
@mihai 我把它拿出来了,现在它说无法获得稳定的行集
-
@mihai 无论有没有不同,我都会收到相同的消息。