2015-10-07 70 views
0

我试图用pl_sql 6.0程序翻译一个月份表。Oracle数据库批量更新pl_sql

我想一次执行下面的所有这些指令,只需一个非常简单的代码,就像'选择指令并按F8'一次。

问题是:

没有“;”在每条指令之间,我得到:ORA-00933命令没有正确结束 与“;”在每个指令之间,即时通讯:ORA-00911无效字符 即时通讯新数据库,所以...我没有看到?提前致谢。

update TIME_TABLE t set t.m_description='JANEIRO' where t.m_description like '%JANUARY%' 
update TIME_TABLE t set t.m_description='FEVEREIRO' where t.m_description like '%FEBRUARY%' 
update TIME_TABLE t set t.m_description='MARÇO' where t.m_description like '%MARCH%' 
update TIME_TABLE t set t.m_description='ABRIL' where t.m_description like '%APRIL%' 
... and so on 

回答

0

只要把这些指令中BEGIN ... END,像这样:

BEGIN 
    update TIME_TABLE t set t.m_description='JANEIRO' where t.m_description like '%JANUARY%' 
    update TIME_TABLE t set t.m_description='FEVEREIRO' where t.m_description like '%FEBRUARY%' 
    update TIME_TABLE t set t.m_description='MARÇO' where t.m_description like '%MARCH%' 
    update TIME_TABLE t set t.m_description='ABRIL' where t.m_description like '%APRIL%' 
    ... and so on 
END; 
/
1

更新使用CASE声明。

update TIME_TABLE t 
set t.m_description = (
    case when t.m_description like '%JANUARY%' then 'JANEIRO' 
     when t.m_description like '%FEBRUARY%' then 'FEVEREIRO' 
     when t.m_description like '%MARCH%' then 'MARÇO' 
     when t.m_description like '%APRIL%' then 'ABRIL' 
    else t.m_description 
    end 
)