写了一条完全没有问题的语句,执行时竟然报错
update MAGE a
set a.fxc_xtbh = (select a from text b where a.fxc_xh
= b.fxc_xh)
ERROR at line 2:
ORA-01407: cannot update ('TEXT'.'MAGE'.'FXC_XTBH') to NULL
根据报错信息,FXC_XTBH列并没有赋值为空,text表的a列完全是有值的,为什么会报赋了空值呢
原因就在于mage的表结构上,看一下MAGE的表结构,
create table MAGE
(
FXC_XH NUMBER(12) not
null,
FXC_XH2 NUMBER(12) default 0,
FXC_XTBH VARCHAR2(2) not null
)
FXC_XTBH列的默认值为非空,但是update的时候,并没有把空值给FXC_XTBH。网上找原因,正确的写法应该是这样,后面要加一个where条件,
update MAGE a
set a.fxc_xtbh = (select a from text b where a.fxc_xh
= b.fxc_xh)
where exists (select 1 from tex