insert into...select from...ORA-02287: sequence number not allowed here问题

insert into pk_dailyflux x (x.f_id,phone,f_byte,f_date)
select SEQ_PK_DAILYFLUX.Nextval,a.tel,sum(t.sc_bytes),t.v_date from sz.st_log_bak t,lxh_info a
where length(a.tel)=11 and t.msisdn=a.tel and t.v_date>=to_char(a.addtime,'yyyymmdd') and t.sc_bytes>0
group by a.tel,t.v_date

会报错ORA-02287: sequence number not allowed here

 

可改为:

insert into pk_dailyflux x (x.f_id,phone,f_byte,f_date)
select SEQ_PK_DAILYFLUX.Nextval,b.* from (select a.tel,sum(t.sc_bytes),t.v_date from sz.st_log_bak t,lxh_info a
where length(a.tel)=11 and t.msisdn=a.tel and t.v_date>=to_char(a.addtime,'yyyymmdd') and t.sc_bytes>0
group by a.tel,t.v_date) b

你可能感兴趣的:(sql与数据库)