我在做文字转换时遇到的问题,我先从一个utf8的文件中读数据,然后把其中的文字型数据转换
成utf16的形式,我的代码是这样写的:
o_rec   varchar2(3000);
vnew_con varchar2(50) := 'utf16';
vold_con varchar2(50) := 'utf8';o_rec := utl_raw.cast_to_varchar2(utl_raw.convert(utl_raw.cast_to_raw(o_rec),vnew_con,vold_con));但是总是报 ora-06502 的oracle错误,不知道如何解决,请各位帮忙。

解决方案 »

  1.   

    ORA-06502 PL/SQL: numeric or value error stringCause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2).Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.
      

  2.   

    utl_raw.cast_to_varchar2(utl_raw.convert(utl_raw.cast_to_raw(字段名),'AMERICAN_AMERICA.ZHS16GBK','AMERICAN_AMERICA.WE8DEC'))
    字符集和字符编码要区分
      

  3.   

    试用 utl_raw.cast_to_nvarchar2 函数将转换为 utf16 的字串保存到 nvarchar2 类型中。nvarchar2 类型默认所存储字符集为 utf16
    select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
    而 varchar2 类型存储的字符集取决数据库的字符集
    select * from v$nls_parameters where parameter='NLS_NCHAR_CHARACTERSET';
      

  4.   

    从一个utf8的文件中读数据,然后把其中的文字型数据转换
    成utf16的形式
    为什么要进行转化?