2015-10-07 103 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 
)