2014-02-25 4 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'