CHARACTERSET이 다른 DB간의 한글조회방법

제품 : ORACLE SERVER
작성날짜 : 2003-09-24
CHARACTERSET이 다른 DB 간의 한글 조회 방법
=========================================
PURPOSE
다음의 방법을 single byte 7 bit encoding 을 사용하는 US7ASCII,
WE8DEC 등과 double byte encoding을 사용하는 KO16KSC5601에서 쌍반 간에
한글 data 조회를 가능하게 하는 방법이다.
이 방법은 한 문자에 대한 각 ascii code값에 대해 비교하고 계산하기에
data가 많거나 성능이 문제시 된다면 사용하는 것을 권장하지 않습니다.
Explanation
방법은 다음과 같습니다. 한글 '가'를 예로 들어 설명한다.
1. '가' 라는 data가 있는 쪽에서 다음과 같이 작업합니다.
1) hexa값으로 전환
rawtohex('가') ==> 'B0A1'
'가'를 hexa값으로 전환한다.
2) 일련의 ascii code값을 얻가 위해 변환한다.
translate(rawtohex('가'),'ABCDEF',':;<=>?') ==> ';0:1'
위에서 'ABCDEF'는 숫자 다음에 오는 문자이며 이 문자를 대신하여 ':;<=>?'
로 전환한다.
':;<=>?'는 ASCII의 숫자 다음에 오는 문자이다.
이와 같이 작업을 하는 이유는 16진수 경우 9라는 숫자 다음에 오는 A,B..F가
숫자 다음의 ascii code 값을
갖지 않기 때문에 그 다음의 문자로 대체한다.
3) data가 있는 쪽에서 view를 만든다.
SELECT translate(rawtohex(column_name),'ABCDEF',':;<=>?') as name FROM
tablename;
2. data를 보려는 쪽에서 다음과 같이 view를 만들거나 select한다.
위에서 저장된 data를 보면 ';0:1' 인데 이의 각 문자별 ascii code값은
59,48,58,49이다.
이를 원래의 ascii code값으로 변경한다.
single byte 7 bit encoding에서는 다음의 방법으로 계산된다. (48은 0의
ascii code값이다)
((59-48)*16)+(48-48))||((58-48)*16)+(49-48) 즉, 176 || 161
하지만 double byte encoding에서는 위의 방법이 불가하며
chr(176*256 + 161) 해야 '가' 가 반환된다.
single byte 7 bit encoding에서는 '가'에 대한 문자가 각 8bit에 대해
chr(176)||chr(161)으로 계산이 가능하나 double byte encoding에서는 이 방
법은 불가하며 앞의 8bit에 대해서 2의 8승인 256을 곱해야 정상적인 문자가
반환이 된다.
또한 한글과 영문, 숫자가 섞여 있을 경우는 무조건 256만을 곱할 수가 없다.
한글만 256을 곱한다.
이에 대한 예는 아래의 function에서 설명한다.
3. 각 case별 test 내역
test는 US7ASCII와 KO16KSC5601 db간의 한글 data를 조회한 예이다.
KO16KSC561의 younkim table과 US7ASCII의 younkim2 table에 대한 data는
다음과 같다. (data내용은 같게했음)
NO NAME
1 김재연
2 김은영
3 이상헌
4 ADAMS
5 SCOTT
6 JAMES
7 이상헌2
8 test12임
9 30하하
10 scott동생
US7ASCII에서 KO16KSC5601 의 한글조회시 다음과 같다.
SQL> select * from younkim@ko;
NO NAME
1 ???
2 ???
3 ???
4 ADAMS
5 SCOTT
6 JAMES
7 ???2
8 test12?
9 30??
10 scott??
물론 KO16KSC5601에서 US7ASCII의 한글 조회시도 다음과 같이 알아 볼수가
없다.
SQL> select * from younkim2@us;
NO NAME
1 1h@g?,
2 1h@:?5
3 @L;sGe
4 ADAMS
5 SCOTT
6 JAMES
7 @L;sGe2
8 test12@S
9 30GOGO
10 scott5?;}
1) US7ASCII에서 KO16KSC560에 있는 data조회 방법
a. KO16KSC5601에서 view를 만든다.
먼저 US7ASCII에서 KO16KSC560에 있는 younkim table에 대한 data를 조회하기
위해서는 다음과 같이 먼저
KO16KSC5601에서 view를 만든다.
SQL> create view younkim_v
2 as select translate(rawtohex(name),'ABCDEF',':;<=>?') as name from
younkim
3 ;
View created.
이를 조회하면 다음과 같다.
SQL> select * from younkim_v;
NAME
;1>8<0>7;?:<
;1>8<0;:;?;5
<0<<;;?3<7>5
4144414=53
53434?5454
4:414=4553
<0<<;;?3<7>532
746573743132<0=3
3330<7<?<7<?
73636?7474;5;?;;?=
10 rows selected.
b. US7ASCII에서도 view를 만들어서 한글 data를 query한다.
create view younkim_usv
as select chr(((ascii(substr(name,1,1)) - 48 )* 16) +
(ascii(substr(name,2,1)) - 48 )) ||
chr( ((ascii(substr(name,3,1)) - 48 )* 16) +
(ascii(substr(name,4,1)) - 48 )) ||
chr( ((ascii(substr(name,5,1)) - 48 )* 16) +
(ascii(substr(name,6,1)) - 48 )) ||
chr( ((ascii(substr(name,7,1)) - 48 )* 16) +
(ascii(substr(name,8,1)) - 48 )) ||
chr( ((ascii(substr(name,9,1)) - 48 )* 16) +
(ascii(substr(name,10,1)) - 48 )) ||
chr( ((ascii(substr(name,11,1)) - 48 )* 16) +
(ascii(substr(name,12,1)) - 48 )) ||
chr( ((ascii(substr(name,13,1)) - 48 )* 16) +
(ascii(substr(name,14,1)) - 48 )) ||
chr( ((ascii(substr(name,15,1)) - 48 )* 16) +
(ascii(substr(name,16,1)) - 48 )) ||
chr( ((ascii(substr(name,17,1)) - 48 )* 16) +
(ascii(substr(name,18,1)) - 48 )) ||
chr( ((ascii(substr(name,19,1)) - 48 )* 16) +
(ascii(substr(name,20,1)) - 48 )) name
from younkim_v@ko, dual
SQL> select * from younkim_usv;
NAME
김재연
김은영
이상헌
ADAMS
SCOTT
JAMES
이상헌2
test12임
30하하
scott동생
10 rows selected.
2) KO16KSC560에서 US7ASCII에 있는 data조회 방법
a. US7ASCII에서 view를 만든다.
create view younkim2_v
as SELECT translate(rawtohex(name),'ABCDEF',':;<=>?') as name FROM
younkim2;
b. KO16KSC560에서 다음과 같이 function을 만들어서 이를 통한 조회를
한다.
한글을 제외하고 한 문자의 ascii code에 대한 hexadecimal값은 00 ~ 7f범위
안에 있으며 view를 통해 생성된 값은 맨 앞의 값이 7보다 크다면 이는 한글이므로 아래와 같이 7보다 큰 ascii code값으로 비교한다.
위의 data를 예로 들어 '김재연'의 경우 ';1>8<0>7;?:<'값으로 미리 view에
만들었으며 '김'에 대한 값은 ';1>8'으로 지정되어 있으며 다음 문자인 '재'를 읽으려면 4번째 다음부터 읽어야 한다.
하지만 영문 data인 'ADAMS'의 경우는 '4144414=53'이며 'A'에 대한 값은
'41'이며 다음 값은 2번째 다음부터 읽어야 한다.
한 문자에 대해 한글이냐 영문, 숫자냐에 따라서 읽고 계산 방법을 다음과
같이 다르게 한다.
create or replace function conv(name varchar2) return varchar2
as
i integer;
kscstring varchar2(100);
begin
i := 1;
kscstring := '';
WHILE i <= lengthb(name) LOOP
IF(ascii(substr(name,i,1)) > ascii('7')) THEN
kscstring := kscstring || chr( ( (ascii(substr(name,i,1)) - 48)*16 +
(ascii(substr(name,i+1,1)) - 48) )*256 + (ascii(substr(name,i+2,1)) -
48)*16 + (ascii(substr(name,i+3,1)) - 48) );
i := i + 4;
ELSE
kscstring := kscstring || chr( (ascii(substr(name,i,1)) - 48)*16 +
(ascii(substr(name,i+1,1)) - 48) );
i := i + 2;
END IF;
END LOOP;
return kscstring;
end;
SQL> select conv(name) from younkim2_v@us;
CONV(NAME)
김재연
김은영
이상헌
ADAMS
SCOTT
JAMES
이상헌2
test12임
30하하
scott동생
10 rows selected.

Similar Messages

  • CSSCAN in 11g - Characterset not changing from WE8IMSWIN1252 to AL32UTF8

    All,
    We have installed a 11g database in Linux box and once after that we wanted to change the character set to AL32UTF8 from default WE8MSWIN1252.
    We took the cs-alter approach and ran cs-scan utility, upon going through csscan.txt files generated by csscan utility we found that there are no lossy data but convertible data was found in data dictionary. Below is the output from csscan.txt
    This is the Scan Summary
    *[Scan Summary]*
    All character type data in the data dictionary are convertible to the new character set
    All character type application data are convertible to the new character set
    Database Scan Summary Report
    Time Started  : 2012-10-17 21:42:17
    Time Completed: 2012-10-17 21:42:47
    Process ID         Time Started       Time Completed
             1  2012-10-17 21:42:18  2012-10-17 21:42:46
             2  2012-10-17 21:42:18  2012-10-17 21:42:46
             3  2012-10-17 21:42:18  2012-10-17 21:42:46
    [Database Size]
    Tablespace                           Used            Free           Total       Expansion
    SYSTEM                            709.75M         256.00K         710.00M           2.42M
    SYSAUX                            645.63M          34.38M         680.00M          12.52M
    UNDOTBS1                           13.13M          16.88M          30.00M            .00K
    TEMP                                 .00K            .00K            .00K            .00K
    USERS                               1.31M           3.69M           5.00M            .00K
    HYPE_DATA                       1,024.00K      19,999.00M      20,000.00M            .00K
    HYPE_INDX                       1,024.00K      19,999.00M      20,000.00M            .00K
    Total                           1,371.81M      40,053.19M      41,425.00M          14.94M
    The size of the largest CLOB is 1625114 bytes
    [Database Scan Parameters]
    Parameter                      Value
    CSSCAN Version                 v2.1
    Instance Name                  dvhp081
    Database Version               11.2.0.3.0
    Scan type                      Full database
    Scan CHAR data?                YES
    Database character set         WE8MSWIN1252
    FROMCHAR                       WE8MSWIN1252
    TOCHAR                         al32utf8
    Scan NCHAR data?               NO
    Array fetch buffer size        10240
    Number of processes            3
    Capture convertible data?      NO
    [Scan Summary]
    All character type data in the data dictionary are convertible to the new character set
    All character type application data are convertible to the new character set
    [Data Dictionary Conversion Summary]
    Data Dictionary Tables:
    Datatype                    Changeless      Convertible       Truncation            Lossy
    VARCHAR2                     5,408,302                0                0                0
    CHAR                             4,261                0                0                0
    LONG                           249,018                0                0                0
    CLOB                            67,652            3,794                0                0
    VARRAY                          49,807                0                0                0
    Total                        5,779,040            3,794                0                0
    Total in percentage             99.934%           0.066%           0.000%           0.000%
    The data dictionary can be safely migrated using the CSALTER script
    XML CSX Dictionary Tables:
    Datatype                    Changeless      Convertible       Truncation            Lossy
    VARCHAR2                           702                0                0                0
    CHAR                                 0                0                0                0
    LONG                                 0                0                0                0
    CLOB                                 0                0                0                0
    VARRAY                               0                0                0                0
    Total                              702                0                0                0
    Total in percentage            100.000%           0.000%           0.000%           0.000%
    [Application Data Conversion Summary]
    Datatype                    Changeless      Convertible       Truncation            Lossy
    VARCHAR2                     2,550,581                0                0                0
    CHAR                                 0                0                0                0
    LONG                                 0                0                0                0
    CLOB                            22,187            8,287                0                0
    VARRAY                               0                0                0                0
    Total                        2,572,768            8,287                0                0
    Total in percentage             99.679%           0.321%           0.000%           0.000%
    [Distribution of Convertible, Truncated and Lossy Data by Table]
    Data Dictionary Tables:
    USER.TABLE                                              Convertible       Truncation            Lossy
    MDSYS.SDO_COORD_OP_PARAM_VALS                                   200                0                0
    MDSYS.SDO_GEOR_XMLSCHEMA_TABLE                                    1                0                0
    MDSYS.SDO_STYLES_TABLE                                           78                0                0
    MDSYS.SDO_XML_SCHEMAS                                             5                0                0
    SYS.METASTYLESHEET                                              179                0                0
    SYS.RULE$                                                         1                0                0
    SYS.SCHEDULER$_EVENT_LOG                                        356                0                0
    SYS.WRH$_SQLTEXT                                                537                0                0
    SYS.WRH$_SQL_PLAN                                               514                0                0
    SYS.WRI$_ADV_DIRECTIVE_META                                       5                0                0
    SYS.WRI$_ADV_OBJECTS                                             28                0                0
    SYS.WRI$_ADV_SQLT_PLANS                                           2                0                0
    SYS.WRI$_ADV_SQLT_PLAN_STATS                                      2                0                0
    SYS.WRI$_DBU_FEATURE_METADATA                                   193                0                0
    SYS.WRI$_DBU_FEATURE_USAGE                                        9                0                0
    SYS.WRI$_DBU_HWM_METADATA                                        21                0                0
    SYS.WRI$_REPT_FILES                                              27                0                0
    SYSMAN.MGMT_IP_ELEM_DEFAULT_PARAMS                              130                0                0
    SYSMAN.MGMT_IP_REPORT_ELEM_PARAMS                             1,475                0                0
    SYSMAN.MGMT_IP_SQL_STATEMENTS                                    31                0                0
    XML CSX Dictionary Tables:
    USER.TABLE                                              Convertible       Truncation            Lossy
    Application Data:
    USER.TABLE                                              Convertible       Truncation            Lossy
    APEX_030200.WWV_FLOW_BANNER                                      10                0                0
    APEX_030200.WWV_FLOW_BUTTON_TEMPLATES                            12                0                0
    APEX_030200.WWV_FLOW_CUSTOM_AUTH_SETUPS                          19                0                0
    APEX_030200.WWV_FLOW_FLASH_CHART_SERIES                           5                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES                             298                0                0
    APEX_030200.WWV_FLOW_PAGE_GENERIC_ATTR                           44                0                0
    APEX_030200.WWV_FLOW_PAGE_PLUGS                               3,240                0                0
    APEX_030200.WWV_FLOW_PAGE_PLUG_TEMPLATES                        254                0                0
    APEX_030200.WWV_FLOW_PROCESSING                                  45                0                0
    APEX_030200.WWV_FLOW_ROW_TEMPLATES                               66                0                0
    APEX_030200.WWV_FLOW_SHORTCUTS                                   39                0                0
    APEX_030200.WWV_FLOW_STEPS                                    1,795                0                0
    APEX_030200.WWV_FLOW_STEP_PROCESSING                          2,238                0                0
    APEX_030200.WWV_FLOW_TEMPLATES                                  192                0                0
    APEX_030200.WWV_FLOW_WORKSHEETS                                  30                0                0
    [Distribution of Convertible, Truncated and Lossy Data by Column]
    Data Dictionary Tables:
    USER.TABLE|COLUMN                                       Convertible       Truncation            Lossy
    MDSYS.SDO_COORD_OP_PARAM_VALS|PARAM_VALUE_FILE                  200                0                0
    MDSYS.SDO_GEOR_XMLSCHEMA_TABLE|XMLSCHEMA                          1                0                0
    MDSYS.SDO_STYLES_TABLE|DEFINITION                                78                0                0
    MDSYS.SDO_XML_SCHEMAS|XMLSCHEMA                                   5                0                0
    SYS.METASTYLESHEET|STYLESHEET                                   179                0                0
    SYS.RULE$|CONDITION                                               1                0                0
    SYS.SCHEDULER$_EVENT_LOG|ADDITIONAL_INFO                        356                0                0
    SYS.WRH$_SQLTEXT|SQL_TEXT                                       537                0                0
    SYS.WRH$_SQL_PLAN|OTHER_XML                                     514                0                0
    SYS.WRI$_ADV_DIRECTIVE_META|DATA                                  5                0                0
    SYS.WRI$_ADV_OBJECTS|ATTR4                                       28                0                0
    SYS.WRI$_ADV_SQLT_PLANS|OTHER_XML                                 2                0                0
    SYS.WRI$_ADV_SQLT_PLAN_STATS|OTHER                                2                0                0
    SYS.WRI$_DBU_FEATURE_METADATA|INST_CHK_LOGIC                     22                0                0
    SYS.WRI$_DBU_FEATURE_METADATA|USG_DET_LOGIC                     171                0                0
    SYS.WRI$_DBU_FEATURE_USAGE|FEATURE_INFO                           9                0                0
    SYS.WRI$_DBU_HWM_METADATA|LOGIC                                  21                0                0
    SYS.WRI$_REPT_FILES|SYS_NC00005$                                 27                0                0
    SYSMAN.MGMT_IP_ELEM_DEFAULT_PARAMS|VALUE                        130                0                0
    SYSMAN.MGMT_IP_REPORT_ELEM_PARAMS|VALUE                       1,475                0                0
    SYSMAN.MGMT_IP_SQL_STATEMENTS|SQL_STATEMENT                      31                0                0
    XML CSX Dictionary Tables:
    USER.TABLE|COLUMN                                       Convertible       Truncation            Lossy
    Application Data:
    USER.TABLE|COLUMN                                       Convertible       Truncation            Lossy
    APEX_030200.WWV_FLOW_BANNER|BANNER                               10                0                0
    APEX_030200.WWV_FLOW_BUTTON_TEMPLATES|TEMPLATE                   12                0                0
    APEX_030200.WWV_FLOW_CUSTOM_AUTH_SETUPS|AUTH_FUNC                 8                0                0
    APEX_030200.WWV_FLOW_CUSTOM_AUTH_SETUPS|PAGE_SENT                10                0                0
    APEX_030200.WWV_FLOW_CUSTOM_AUTH_SETUPS|POST_AUTH                 1                0                0
    APEX_030200.WWV_FLOW_FLASH_CHART_SERIES|SERIES_QU                 5                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|ITEM_TEMPLATE                20                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|ITEM_TEMPLATE                20                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|LIST_TEMPLATE               105                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|LIST_TEMPLATE               105                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|SUB_LIST_ITEM                12                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|SUB_LIST_ITEM                12                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|SUB_TEMPLATE_                12                0                0
    APEX_030200.WWV_FLOW_LIST_TEMPLATES|SUB_TEMPLATE_                12                0                0
    APEX_030200.WWV_FLOW_PAGE_GENERIC_ATTR|ATTRIBUTE_                44                0                0
    APEX_030200.WWV_FLOW_PAGE_PLUGS|PLUG_SOURCE                   3,240                0                0
    APEX_030200.WWV_FLOW_PAGE_PLUG_TEMPLATES|TEMPLATE               166                0                0
    APEX_030200.WWV_FLOW_PAGE_PLUG_TEMPLATES|TEMPLATE                88                0                0
    APEX_030200.WWV_FLOW_PROCESSING|PROCESS_SQL_CLOB                 45                0                0
    APEX_030200.WWV_FLOW_ROW_TEMPLATES|ROW_TEMPLATE1                 54                0                0
    APEX_030200.WWV_FLOW_ROW_TEMPLATES|ROW_TEMPLATE2                 10                0                0
    APEX_030200.WWV_FLOW_ROW_TEMPLATES|ROW_TEMPLATE3                  2                0                0
    APEX_030200.WWV_FLOW_SHORTCUTS|SHORTCUT                          39                0                0
    APEX_030200.WWV_FLOW_STEPS|HELP_TEXT                          1,513                0                0
    APEX_030200.WWV_FLOW_STEPS|HTML_PAGE_HEADER                     282                0                0
    APEX_030200.WWV_FLOW_STEP_PROCESSING|PROCESS_SQL_             2,238                0                0
    APEX_030200.WWV_FLOW_TEMPLATES|BOX                               64                0                0
    APEX_030200.WWV_FLOW_TEMPLATES|FOOTER_TEMPLATE                   64                0                0
    APEX_030200.WWV_FLOW_TEMPLATES|HEADER_TEMPLATE                   64                0                0
    APEX_030200.WWV_FLOW_WORKSHEETS|SQL_QUERY                        30                0                0
    [Indexes to be Rebuilt]
    USER.INDEX on USER.TABLE(COLUMN)
    APEX_030200.WWV_FLOW_WORKSHEETS_UNQ_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(SYS_NC00078$)
    APEX_030200.WWV_FLOW_WORKSHEETS_UNQ_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(SYS_NC00079$)
    APEX_030200.WWV_FLOW_WORKSHEETS_UNQ_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(SYS_NC00080$)
    APEX_030200.WWV_FLOW_WORKSHEETS_UNQ_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(SYS_NC00081$)
    APEX_030200.WWV_FLOW_WS_UNQ_ALIAS_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(SYS_NC00082$)
    APEX_030200.WWV_FLOW_WS_UNQ_ALIAS_IDX on APEX_030200.WWV_FLOW_WORKSHEETS(ALIAS)
    ----------------------------------------------------------------------------------We followed few metalink documents *Solving Convertible or Lossy data in Data Dictionary objects reported by Csscan when changing the NLS_CHARACTERSET [ID 258904.1]* and found that we are good to go as convertible was found only in data dictionary and that too CLOB data. But while running csalter.plb csalter came out without changing the characterset. We ran the following query given the said document and it returned no rows which again confirms there is no problem and go ahead with running csalter.
    SELECT DISTINCT z.owner_name
    || '.'
    || z.table_name
    || '('
    || z.column_name
    || ') - '
    || z.column_type
    || ' - '
    || z.error_type
    || ' ' NotHandledDataDictColumns
    FROM csmig.csmv$errors z
    WHERE z.owner_name IN
    (SELECT DISTINCT username FROM csmig.csm$dictusers
    ) minus
    SELECT DISTINCT z.owner_name
    || '.'
    || z.table_name
    || '('
    || z.column_name
    || ') - '
    || z.column_type
    || ' - '
    || z.error_type
    || ' ' DataDictConvCLob
    FROM csmig.csmv$errors z
    WHERE z.error_type ='CONVERTIBLE'
    AND z.column_type = 'CLOB'
    AND z.owner_name IN
    (SELECT DISTINCT username FROM csmig.csm$dictusers
    ORDER BY NotHandledDataDictColumns
    /Sorry to have made the thread so big but to make sure and give a complete picture of the issue pasted the csscan contents. Request the PRO's to help us in this issue.

    You have convertible data in the application tables. CLOB or not, such data prevents csalter.plb from changing the character set.
    You are on 11.2.0.3, so use the DMU (http://www.oracle.com/technetwork/products/globalization/dmu/overview/index.html). It can cope with such data.
    -- Sergiusz

  • How to open a file in the correct characterset

    Apex 3.1 running on OracleXe
    I have a file which I open using an onlaod before header process (similar to the way excel files are opened).
    I set the Mime Type in the header process on an apex page
    OWA_UTIL.mime_header ('Application/Octet', FALSE);
    -- Set the name of the file
    htp.p('Content-Disposition: attachment; filename="'||:P12_FILENAME||'"');
    -- Close the HTTP Header
    owa_util.http_header_close;and then generate a query via a stored procedure which I write out using the following routine
    (It is done this way as the file needs to be written to the client machine rather than the database server).
    Procedure Dump_Query_To_File(P_Query                In Varchar2,
                                 P_Display_Titles       In Varchar2 Default 'N')
    IS
        l_output utl_file.file_type;
        L_Thecursor Integer Default Dbms_Sql.Open_Cursor;
        L_Columnvalue Varchar2(4000);
        L_Status Integer;
        l_query VARCHAR2(4000) := p_query;
        L_Colcnt Number        := 0;
        L_Separator Varchar2(1) := '';
        L_Desctbl Dbms_Sql.Desc_Tab;
    begin
        Dbms_Sql.Parse(L_Thecursor,   L_Query,   Dbms_Sql.Native);
        dbms_sql.describe_columns(l_thecursor,   l_colcnt,   l_desctbl);
        For I In 1 .. L_Colcnt
        Loop
            If P_Display_Titles ='Y'
            Then
                If I < L_Colcnt
                Then
                    Htp.Prn(L_Separator || '"' || L_Desctbl(I).Col_Name || '"');
                    L_Separator := ';';
                Elsif I = L_Colcnt
                Then
                    Htp.Prn(L_Separator || '"' || L_Desctbl(I).Col_Name || '"');
                    htp.ps(chr(13));
                End If;
            END IF;
            Dbms_Sql.Define_Column(L_Thecursor,   I,   L_Columnvalue,   4000);
        End Loop;
        L_Status := Dbms_Sql.Execute(L_Thecursor);
        WHILE(dbms_sql.fetch_rows(l_thecursor) > 0)
        LOOP
          l_separator := '';
          FOR i IN 1 .. l_colcnt
          Loop
              Dbms_Sql.Column_Value(L_Thecursor,   I,   L_Columnvalue);
              If I <= L_Colcnt
              then
                  Htp.Prn(L_Separator || L_Columnvalue);
                  L_Separator := ';';
              end if;
          End Loop;
          htp.ps(chr(13));
        End Loop;
       dbms_sql.close_cursor(l_thecursor);
    End Dump_Query_To_File;When I vew the file in notepad I can see a string Annulé
    but when I open it in wordpad this gets converted to Annulé.
    Ideally what I need to do is open the file using characterset WE8MSWIN1252
    and write to the file using the same characterset.
    My database is in AL32UTF8 (ie XE universal Edition).
    So far the information I have is that owa_util only accepts charactersets when the mime type is of type text.
    This however still results in the file being written with the incorrect characterset.
    Edited by: Keith Jamieson on Oct 27, 2010 12:16 PM

    Small update.
    I created a database with a western european characterset We8MSWIn1252
    If I use utl_file to write out the code on the database server it gets produced correctly in Ascii format with the accented charcacters.
    As soon as I try and write out the code using owa_util.Mime_header and htp.p the code is written in UTF8 format.
    I did try and write out the header specifying a western european characterset but it seems that if it encounters an accented character it automatically switches to utf-8 mode. If there are no accented charcters the file is produced in ascii format.
    Really stumped on this one.

  • Unicode Migration using National Characterset data types - Best Practice ?

    I know that Oracle discourages the use of the national characterset and national characterset data types(NCHAR, NVARCHAR) but that is the route my company has decide to take and I would like to know what is the best practice regarding this specifically in relation to stored procedures.
    The database schema is being converted by changing all CHAR, VARCHAR and CLOB data types to NCHAR, NVARCHAR and NCLOB data types respectively and I would appreciate any suggestions regarding the changes that need to be made to stored procedures and if there are any hard and fast rules that need to be followed.
    Specific questions that I have are :
    1. Do CHAR and VARCHAR parameters need to be changed to NCHAR and NVARCHAR types ?
    2. Do CHAR and VARCHAR variables need to be changed to NCHAR and NVARCHAR types ?
    3. Do string literals need to be prefixed with 'N' in all cases ? e.g.
    in variable assignments - v_module_name := N'ABCD'
    in variable comparisons - IF v_sp_access_mode = N'DL'
    in calls to other procedures passing string parameters - proc_xyz(v_module_name, N'String Parameter')
    in database column comparisons - WHERE COLUMN_XYZ = N'ABCD'
    If anybody has been through a similar exercise, please share your experience and point out any additional changes that may be required in other areas.
    Database details are as follows and the application is written in COBOL and this is also being changed to be Unicode compliant:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    NLS_CHARACTERSET = WE8MSWIN1252
    NLS_NCHAR_CHARACTERSET = AL16UTF16

    ##1. while doing a test convertion I discovered that VARCHAR paramaters need to be changed to NVARCHAR2 and not VARCHAR2, same for VARCHAR variables.
    VARCHAR columns/parameters/variables should not by used as Oracle reserves the right to change their semantics in the future. You should use VARCHAR2/NVARCHAR2.
    ##3. Not sure I understand, are you saying that unicode columns(NVARCHAR2, NCHAR) in the database will only be able to store character strings made up from WE8MSWIN1252 characters ?
    No, I meant literals. You cannot include non-WE8MSWIN1252 characters into a literal. Actually, you can include them under certain conditions but they will be transformed to an escaped form. See also the UNISTR function.
    ## Reason given for going down this route is that our application works with SQL Server and Oracle and this was the best option
    ## to keep the code/schemas consistent between the two databases
    First, you have to keep two sets of scripts anyway because syntax of DDL is different between SQL Server and Oracle. There is therefore little benefit of just keeping the data type names the same while so many things need to be different. If I designed your system, I would use a DB-agnostic object repository and a script generator to produce either SQL Server or Oracle scripts with the appropriate data types or at least I would use some placeholder syntax to replace placeholders with appropriate data types per target system in the application installer.
    ## I don't know if it is possible to create a database in SQL Server with a Unicode characterset/collation like you can in Oracle, that would have been the better option.
    I am not an SQL Server expert but I think VARCHAR data types are restricted to Windows ANSI code pages and those do not include Unicode.
    -- Sergiusz

  • Characterset mismatch error while export

    Hi,
    I am getting characterset mismatch error while exporting a schema.
    select * from nls_database_parameters where parameter in('NLS_LANGUAGE','NLS_TERRITORY','NLS_CHARACTERSET')
    PARAMETER
    VALUE
    NLS_LANGUAGE
    AMERICAN
    NLS_TERRITORY
    AMERICA
    NLS_CHARACTERSET
    AL32UTF8
    i have set nls_lang on OS level
    NLS_LANG = AMERICAN_AMERICA.AL32UTF8
    C:\oracle\ora92\bin>
    C:\oracle\ora92\bin>
    C:\oracle\ora92\bin>exp hrtemp_v6/hrtemp_v6@testdb file=c:\hrtemp_v6 statistics=
    none
    Export: Release 9.2.0.1.0 - Production on Mon May 14 11:55:58 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Export done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
    server uses AL32UTF8 character set (possible charset conversion)
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user HRTEMP_V6
    . exporting PUBLIC type synonyms
    EXP-00008: ORACLE error 6552 encountered
    ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-553: character set name is not recognized
    EXP-00000: Export terminated unsuccessfully
    please suggest , whats wrong here
    thanks & regards

    i have set nls_lang on OS level
    NLS_LANG = AMERICAN_AMERICA.AL32UTF8How and where?
    C:\oracle\ora92\bin>At this command prompt, what do you get back from "set nls"
    You can use
    c:\> set nls_lang=.al32utf8
    ...right before you issue exp command.

  • Data not viewable in table using Control file  CharacterSet AL32UTF8

    i have a flat file which contains Chinese characters and English Characters
    I have to create a control file, to insert the data in this flat file to the Table
    The characterset i am using in my control file is AL32UTF8
    When i use this characterset the data is getting loaded into the table,but i am not able to view the Chinese characters.
    i am able to see some Upside down question mark symbol
    Please help me of how to view the chinese characters into the table
    Is that any other characterset i have to set in Control file

    NLS_LANG is an environment variable. I'm assuming you're on Windows, so it's probably something like
    Control Panel | System | Advanced | Environment Variables
    Given that you're using Toad, though, there may be someplace there where you set the character set. There is a discussion on Eddie Awad's blog on how various tools can be made to display Unicode data
    http://awads.net/wp/2006/07/06/sql-developer-and-utf8/
    Some of the comments discuss Toad, though that's not a tool I'm familiar with.
    If you happen to be able to use iSQL*Plus, since that's browser based, it supports unicode natively. That's often the easiest solution.
    Justin

  • Issue with characterset setting in OWB flat file target

    an OWB mapping reads from the database source and writes to flat file target in unix os but junk characters are displayed for non english characters in the target file . The database table contains french,spanish,german,arabic characters.The nls db parameter setting is AL32UTF8. The same setting has been applied to OWB target also but still junk values are appearing for non english characterset.different charactersets like al32utf8,utf8,utf18,us7ascii have been tried at owb target setting but nothing is wroking out to remove junk characters. Please suggest
    Edited by: 943807 on 30 Jun, 2012 10:43 PM

    Please provide some input on the issue

  • Urgent.. Characterset of flat file target in OWB

    OWB mapping reads from the database source and writes to flat file target in unix os but junk characters are displayed for non english characters in the target file . The database table contains french,spanish,german,arabic characters.The nls db parameter setting is AL32UTF8. The same setting has been applied to OWB target by editing flat file defintion also but still junk values are appearing for non english characterset.different charactersets like al32utf8,utf8,utf18,us7ascii have been tried at owb target setting but nothing is working out to remove junk characters. Please suggest

    Yes this should be fine. Are you using the gateway to access SQLServer or code template mappings? You need to track which columns are throwing the data type conversion errors.
    Cheers
    David

  • Inserting data into a different characterset

    Hi,
    I have an oracle 10g database with WE8ISO8859P1 as the characterset.
    Now we are inserting data into the database with UTF-8 encoding.
    in this situation, will the data get converted to the WE8ISO8859P1 characterset or will the data get corrupted. will we lose the data since it is a different characterset.
    Please help me understand.
    Thanks.
    Philip.

    This is the document i will be following to do the conversion.
    Changing the NLS_CHARACTERSET to AL32UTF8 / UTF8 (Unicode) [ID 260192.1]
    But i don't see any steps for a RAC environment. The database is on a RAC with 2 nodes.
    I believe i have to bring down both the instances to get the database also down, and then i need to only bring one instance up, do the conversion, bring it down and then bring both the instances back up along with the database.
    Can someone tell me the additional steps i need to do in a RAC while doing the conversion.
    Thanks.

  • Problem in JMS-Adapter with CharacterSet Websphere MQ

    Hi,
    we have the following scenario:
    JMS -> PI -> File
    We have a local Websphere MQ Queue Manager and the follwoing configuration in our sender adapter:
    Transport-Protocol: WebSphere MQ (non JMS)
    Message-Protocol: JMS 1.x
    ConnectionFactory: com.ibm.mq.jms.MQQueueConnectionFactory
    Java-class Queue: com.ibm.mq.jms.MQQueue
    CCSID: 819
    Transport: TCP/IP
    JMS-conform: WebSphere MQ (non JMS)
    In the local queue manager the messages (XML-Messages with header <?xml version="1.0" encoding="ISO-8859-1"?>) have characterSet 819 (ISO-8859-1). That's correct. You can open the files with XMLSpy and it works.
    When we receive the messages by our JMS Sender Adapter all the character seems to be in UTF-8 and I don't know why. All the special characters are wrong cause the header of the XML-message shows ISO-8859-1 but all the signs are decoded in UTF-8.
    In the other direction (JMS Receiver adapter, File -> PI - JMS) we have the same problem.
    We create a ISO-8859-1 message in mapping (and it is really ISO-8859-1) and send it via JMS Receiver Adapter to the local message queue. But there the message arrives in UTF-8 encoding. I don't understand this.
    Does anybody know what could be the cause for this?
    Does the JMS adapter convert the messages from ISO-8859-1 into UTF-8?
    Are there any parameters we have to set?
    I hope anybody has an idea what's wrong.
    Regards
    Thorsten
    Edited by: Thorsten Hautz on Oct 12, 2010 5:42 PM

    Hi,
    thanks a lot for your replies.
    our driver settings are correct (as I can see).
    I removed value 819 from CCSID, but we have the same effect.
    The messages in the local queue manager are TextMessages in XML.
    Does anybody know, if we need the standard modules (ConvertJMSMessageToBinary and ConvertBinaryToXMBMessage) in this case?
    Is it possible to set the CCSID for the message payload anywhere in the configuration?
    The CCSID in the Source tab doesn't have any influence to the encoding of the payload message, only to the header data.
    Regards
    Thorsten

  • PDF printing with UTF8 characterset

    Hi,
    Stats:
    E-BIZ version :- 11.5.10.2
    DB:- 10.2.0.3
    Report BUilder :- 6i
    Character Set :- UTF8.
    I have some doubt while viewing/printing pdf reports from Oralce Application. Can you please suggest if it is possible to print pdf's from oracle apps with UTF8 characterset and without having 3rd party software to convert pdf report to postscript and a printer that can understand postscript. We do have PASTA and IX configured in our enviornment.Reports created are in BI/XML publisher.
    Actually we have one 3rd party tool for printing and wanted to get rid of it due to financial constraints. Can you please suggest if it is possible to print pdf's from oracle apps without having 3rd party tool. I have read lot of document and completely lost. Oracle some where says it is possible and at other place says 'If you are on UTF8 chacterset then you need to have XML/BI publisher with PASTA and 3rd party software' but in my enviornment we have some pdf reports that are bypassing 3rd party software for printing. I am just lost.
    Any help would be appreciated
    Thanks,
    JD

    Hi,
    This line confuses me, do i require 3rd party software to print from oracle apps if my characterset is UTF8(althoug i am using XML publisher), I believe yes -- See (Note: 422508.1 - About Oracle XML Publisher Release 5.6.3), Step 8 Enable PDF Printing in Oracle Applications. (System Administrator)
    Workaround section says
    6. From Oracle Applications via the Adobe Acrobat Reader, a PDF output file can be viewed and
    printed.>>>> NO i not want to use it.This is a workaround to print PDF directly from the application. If you do not want to use this approach, use the other one mentioned above.
    7.Although, it may be possible to create a custom print driver or print program using the Adobe
    Acrobat Distiller, viable instructions on how to perform such a custom setup is very scarce, see
    Note 262657.1--intended for Latin 1 character set environments.>>>> I am on UTF8
    I would not recommend this approach as this may (or may not) work.
    8. Use Pasta, an Oracle post printing program, to change a copy of the report output file to the
    desired or printable output format.>>>>>> I have PASTA but does that mean i can print all my pdf reports using it. Don't i need 3rd party tool now.See (Note: 239196.1 - PASTA 3.0 Release Information).
    9. Lastly, use another format like Postscript, that is fully supported for viewing and printing>>>>> How to use it? Can anyone please explain.Change the output of the concurrent program to Postscript (Concurrent > Program > Define), and you can view the output using Ghost Viewer.
    Note: 117112.1 - How to read Postscript File Formats on a MS Windows Operating System and Convert To Another File Format
    Thanks,
    Hussein

  • How to get the unicode escapes for characters outside a characterset

    Hi!
    I'm tryiing to edit into a RTF file and have been fairly successful so far. But living outside the U.S i need some characters outside ASCII. Those characters are supposed to be escaped as unicode-escapes, eg \u45. But I can't find a way to get the escapesequense for the unicode-characters that lives outside ASCII.
    I'm guessing that this is a very simple thing to do but I have not been lucky with google so far.
    So, how do I get the unicode escapes for characters outside a characterset?
    Thanks in advance
    Roland Carlsson

    I'm tryiing to edit into a RTF file and have been
    fairly successful so far. But living outside the U.S
    i need some characters outside ASCII. Those
    characters are supposed to be escaped as
    unicode-escapes, eg \u45. But I can't find a way to
    get the escapesequense for the unicode-characters
    that lives outside ASCII.You are asking about RTF and not java correct?
    As a guess....
    Unicode is 32 bit (presumably you are not using the newest one.) Thus it requires a 32 bit representation. Thus \u45 actually is the same as \u0045. Thus something like \u1e45 would probably work.

  • Forms and reports server characterset aix

    My database is in UTF8 mode and is displaying all characters correctly.
    However when I run a report using the forms and reports server it uses Western European Character Set.
    I have tried re-installing forms and reports server in order to fix this characterset issue, however I am not prompted for a characterset at installation time, so the forms and reports server is still set to the Western European Character Set, thus, some characters are not being displayed (inverse ?).
    I have tried specifying UTF8 for NLS_LANG in reports.sh but I only get garbage displayed.
    Can someone point me in the right direction please

    This issue has now been resolved. Changing the NLS_LANG setting in reports.sh to POLISH_POLAND.UTF8 was correct. The issue then was that greek symbols were displayed. This was a font issue and was resolved by amending a file
    $ORACLE_HOME/guicommon/tk/admin/AFM/fontname (where fontname is the characterset you are using,eg in my case Courier ).
    the Change was to amend the line:
    EncodingSchemeProperty AdobeStandardEncoding
    to read
    EncodingSchemeProperty FontSpecific
    This fixed the problem for me , but Oracle also advise to amend the file $ORACLE_HOME/guicommon/tk/admin/Tk2Motif.rgb:
    eg change the below line from:
    !Tk2Motif*fontMapCs: iso8859-2=EE8ISO8859P2
    to:
    Tk2Motif*fontMapCs: iso8859-2=UTF8 (or whatever charcterset you are using).
    Note that the exclamation mark has been removed.
    Read Oracle Note 300416.1

  • Problem with the Characterset

    We are facing a problem with using the characterset.
    The database characterset is WE8ISO8859P1. In one of the modules
    we need to store some multi-lingual data which also includes
    some chineses and japanese characters.
    So, we tried to change the client(running on windows 98 and db
    server running on a Sun box) NLS_LANG to French_France.UTF8 in
    the registry. Then when we issued the query,
    select userenv('language') from dual;
    French_France.WE8ISO8859P1
    was the output.
    Is it possible to set the client's characterset different from
    the server's character set?

    First, USERENV('language') returns the Language and Territory of
    your user session and the character set of your database (not
    your user session). So, the output from USERENV('language') is
    not your user session character set.
    Second, whether or not you can change your user session
    character set depends on whether or not your client application
    or client terminal supports that character set. By default,
    your user session will use the character set of your terminal.
    If you need, you can change it to the character set of your
    client application (Windows 98 for your case). So, you can
    change the character set to UTF8 only when your platform support
    UTF8.

  • Latin-1 Characterset Translation Issues

    I have an Oracle 9.2.0.5 database on OpenVMS 7.3-2. Currently, there are 101 incorrect Latin-1 to Latin-1 character set translations that are being loaded into my Oracle database (Incorrect OS conversion tables when data is transfered from source system).
    NLS DB parameters (nls parameters not listed are default values):
    nls_language string AMERICAN
    nls_length_semantics string BYTE
    nls_nchar_conv_excp string FALSE
    nls_territory string AMERICA
    example:
    Source Data : Résine de PolyPropylène
    Loaded in my database after OS translation: R©sine de PolyPropyl¬ne
    The invalid translations are happening external to the oracle database at the OS level. My problem is I need to correct all the invalid character sets that are in my database. The database is current 3.5TB in size, so I have to do this in an efficient matter. I know what the before (invalid translations values in HEX) and after (correct translations in HEX) values are.
    Is there a PL/SQL program or Oracle tool that can help me to correct these values against millions of rows of data in Oracle (Basically a characterset translation program)?
    I have a C program that works to convert the charactersets if they are in a CSV file. The problem is it takes to long to extract the data from oracle into CSV files for tables that are multi-millions of rows.
    Any help is appreciated.

    It looks like during the insertion from ASP the Latin 1 string has not been converted to UTF8. Hence you are storing Latin-1 encoding inside a UTF-8 database.
    I thought it would automatically be handled by OO4O.True. Did you specify the character set of the NLS_LANG env variable for the OO4O client to WE8ISO8859P1 ? If it was set to UTF8 then Oracle will assume that the encoding coming thru' the ASP page are in UTF-8 , hence no conversion takes place ..
    Also may be you should check the CODEPAGE directive and Charset property in your ASP ?
    null

  • SOAP receiver adapter for ASCII-7 characterset???

    Hi,
    Our scenario is Abap Proxy -> XI -> Web Services (SOAP Adapter). Receiver webservice will accept only the characterset of ASCII-7. But Abap Proxy will send only unicode characterset (default).
    Any workaround for receiver SOAP adapter to accept ASCII-7 characterset?
    Regards,
    Prasad U

    Hi -
    You can set a specific encoding in the soap receiver channel module configuration.  From the SOAP Adapter FAQ (Note 856597):
    <i>         o  Q: What character encoding is supported by the SOAP receiver
                adapter?
                A: The SOAP receiver adapter can use any character encoding
                supported by the local JDK. The request message from the SOAP
                receiver is normally encoded in UTF-8. If you want to change this
                encoding, for instance to iso-8859-1, you can set parameter
                XMBWS.XMLEncoding to iso-8859-1 in the module configuration for
                the SOAP adapter module. This setting is for the outgoing SOAP
                message and has no effect on the incoming SOAP message. For the
                incoming SOAP message, any code page supported by the local JDK
                is accepted.</i>
    Check the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d23cbe11-0d01-0010-5287-873a22024f79">How to Use the XI 3.0 SOAP Adapter</a> document for an example.
    Regards,
    Jin

Maybe you are looking for