函数从oracle字符串解码到sql server

时间:2013-10-30 14:03:59

标签: string oracle function unicode

我必须为oracle重写一个t-sql函数,所以我想询问是否有可能在Oracle数据库上做类似的事情:

CREATE FUNCTION [dbo].[fn_stor_text_convertion]  (@str_in AS NVARCHAR(100)) 
RETURNS NVARCHAR(100) WITH RETURNS NULL ON NULL INPUT, 
EXECUTE AS CALLER AS BEGIN

DECLARE @str_out NVARCHAR(100);     
DECLARE @position INT;  
DECLARE @char_code INT;

        SET @position = 1   SET @str_out = ''


WHILE @position <= DATALENGTH(@str_in)      
BEGIN           
SET @char_code = UNICODE(SUBSTRING(@str_in, @position, 1))          
SET @char_code =            
CASE

                    WHEN @char_code = 184 THEN 235
                    WHEN @char_code < 192 THEN @char_code
                    ELSE @char_code + 848           
END


SET @str_out = CONCAT(@str_out, NCHAR(@char_code))          
SET @position
    = @position + 1         
END

        RETURN(@str_out) 
END

0 个答案:

没有答案