Table of ContentsPreviousNext

Ispirer             Ispirer


Ispirer SQLWays データベース移行ソフトウェア

Oracle DECODE を MySQL CASEへ変換

Oracle のDECODE 関数は指定された式と各検索値を一つずつ比較し、対応する結果を返すのに使用されます。

MySQL にも DECODE 関数がありますが、それは暗号化された文字列を指定されたパスワードで複合するために使用されます。MySQL のCASE 式が Oracle のDECODE 関数と機能的に等価なものになります。

SQLWays は Oracle のDECODE 関数を MySQL のCASE 式に変換します。

TABLE 34. Oracle DECODE を MySQL CASEへの変換
Oracle
MySQL
create procedure ora_sp_decode2 (job_level out 
varchar2) as
begin 
select DECODE(job_lvl,1,'level 1',2,'level 2','Unknown 
level') into job_level from employee where job_id>0;
end; 
create procedure ora_sp_decode2 (out job_level TEXT ) 
begin 
select CASE job_lvl
WHEN 1 THEN 'level 1
WHEN 2 THEN 'level 2'
ELSE 'Unknown level' end
into job_level from employee where job_id>0   ;
end ; 


Table of ContentsPreviousNext
Ispirer             Ispirer
Copyright © 1999-2015 Ispirer Systems Ltd. Ispirer and SQLWays are trademarks of Ispirer Systems Ltd. All other product names may be trademarks of the respective companies. All rights reserved.