2014-02-25 88 views
0

有人能帮我修改这条SQL语句,以便它能在Oracle环境中工作吗?Oracle SQL更新声明

update tbraccd 
join ttbtaxn on tbraccd.pidm = ttbtaxn.pidm 
set tbraccd_effective_date = '01-JAN-2014', tbraccd_entry_date = '01-JAN-2014' 
where tbraccd_detail_code = 'VPMT' 
and tbraccd_effective_date = '31-DEC-2013' 
and (tbraccd_entry_date > '31-DEC-2013' and tbraccd_entry_date < '01-JAN-2014') 
and tbraccd_term_code = '201410' 
and ttbtaxn_stud_notif_status = 'E' 
and ttbtaxn_tax_year = '2013' 

回答

0
update tbraccd 
    set tbraccd_effective_date = '01-JAN-2014', 
     tbraccd_entry_date = '01-JAN-2014' 
where tbraccd_detail_code = 'VPMT' 
and tbraccd_effective_date = '31-DEC-2013' 
and (tbraccd_entry_date > '31-DEC-2013' 
and tbraccd_entry_date < '01-JAN-2014') 
and tbraccd_term_code = '201410' 
and exists 
    (select 'X' from ttbtaxn 
     where tbraccd.pidm = ttbtaxn.pidm 
     and ttbtaxn_stud_notif_status = 'E' 
     and ttbtaxn_tax_year = '2013') 
0

假设在键保存视图连接结果,你可以这样做:

update 
(
select 
     tbraccd_effective_date, 
     tbraccd_entry_date 
from 
     tbraccd 
     join ttbtaxn 
     on tbraccd.pidm = ttbtaxn.pidm 
where 
     tbraccd_detail_code = 'VPMT' 
     and tbraccd_effective_date = '31-DEC-2013' 
     and (tbraccd_entry_date > '31-DEC-2013' and tbraccd_entry_date <'01-JAN-2014') 
     and tbraccd_term_code = '201410' 
     and ttbtaxn_stud_notif_status = 'E' 
     and ttbtaxn_tax_year = '2013' 
) 
set 
     tbraccd_effective_date = '01-JAN-2014', 
     tbraccd_entry_date ='01-JAN-2014'