简体   繁体   English

Oracle SQL更新语句

[英]Oracle SQL Update Statement

Could someone please help me modify this SQL statement so it will work in an Oracle environment? 有人可以帮我修改此SQL语句,使其在Oracle环境中工作吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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