從utf8轉到US7ASCII

wei-xh發表於2010-09-15

資料庫A為UTF8字符集。

資料庫B為US7ASCII字符集。

資料庫A端,根據基表建立檢視,使用到utl_raw.cast_to_raw函式:

CREATE or replace VIEW B$APP_CLOT_INFO AS SELECT
 ID,
 GMT_CREATE,
 utl_raw.cast_to_raw(CREATOR) AS CREATOR,
 GMT_MODIFIED,
 utl_raw.cast_to_raw(MODIFIER) AS MODIFIER,
 IS_DELETED,
 utl_raw.cast_to_raw(NAME) AS NAME,
 SQL,
 utl_raw.cast_to_raw(OBJ_CLASS_NAME) AS OBJ_CLASS_NAME,
 utl_raw.cast_to_raw(KEY_NAME) AS KEY_NAME,
 utl_raw.cast_to_raw(PARENT) AS PARENT,
 utl_raw.cast_to_raw(GROUPS) AS GROUPS,
 utl_raw.cast_to_raw(SCHEDULE_STR) AS SCHEDULE_STR,
 LOAD_ORDER,
 utl_raw.cast_to_raw(COMMENTS) AS COMMENTS
FROM APOLLO.APP_CLOT_INFO;

資料庫B端:

  SELECT ID,
         GMT_CREATE,
         convert(utl_raw.cast_to_varchar2(CREATOR), 'zhs16gbk', 'utf8') AS CREATOR,
         GMT_MODIFIED,
         convert(utl_raw.cast_to_varchar2(MODIFIER), 'zhs16gbk', 'utf8') AS MODIFIER,
         IS_DELETED,
         convert(utl_raw.cast_to_varchar2(NAME), 'zhs16gbk', 'utf8') AS NAME,
         SQL,
         convert(utl_raw.cast_to_varchar2(OBJ_CLASS_NAME),
                 'zhs16gbk',
                 'utf8') AS OBJ_CLASS_NAME,
         convert(utl_raw.cast_to_varchar2(KEY_NAME), 'zhs16gbk', 'utf8') AS KEY_NAME,
         convert(utl_raw.cast_to_varchar2(PARENT), 'zhs16gbk', 'utf8') AS PARENT,
         convert(utl_raw.cast_to_varchar2(GROUPS), 'zhs16gbk', 'utf8') AS GROUPS,
         convert(utl_raw.cast_to_varchar2(SCHEDULE_STR), 'zhs16gbk', 'utf8') AS SCHEDULE_STR,
         LOAD_ORDER,
         convert(utl_raw.cast_to_varchar2(COMMENTS), 'zhs16gbk', 'utf8') AS COMMENTS
    FROM ;

可以解決亂碼問題。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-674002/,如需轉載,請註明出處,否則將追究法律責任。

相關文章