--用B表字段更新A表字段 UPDATE ( select a.is_work iswork from dim_time a ,(select date_num,is_rest from WORKTIME_SPECIALDAY@oa ) b where a.fdate = b.date_num and b.IS_REST !=0 --order by a.fdate )t set t.iswork =1;
报错:
原因:B表去更新A表字段,在A表和B表关联的时候,B表date_num不是主键或date_num字段没有设置唯一键,导致B表date_num里有重复数据
解决办法:
第一种:修改业务数据,使date_num数据唯一
第二种:写一个视图(DIM_WORKTIME_SPECIALDAY),去重之后再更新
select distinct to_date(date_num,'yyyy-mm-dd hh24:mi:ss') as date_num, is_rest from WORKTIME_SPECIALDAY where IS_REST =0 and org_account_id ='670869647114347'
UPDATE ( select a.is_work iswork from dim_time a ,(select date_num,is_rest from DIM_WORKTIME_SPECIALDAY ) b where a.fdate = b.date_num and b.IS_REST !=0 order by a.fdate )t set t.iswork =1;