简体   繁体   中英

Oracle SQL Update Statement

Could someone please help me modify this SQL statement so it will work in an Oracle environment?

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'

Assuming the join results in a key-preserved view, you can do like this:

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'
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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM