Oracle中的字符集不匹配错误

前端之家收集整理的这篇文章主要介绍了Oracle中的字符集不匹配错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我跟随我询问我正在尝试运行:
SELECT Script from (

SELECT 9 as ColOrder,' INSERT INTO PROJ VALUES(' || ID || ',''' || Name || ''',''' || Version || ''',''ABCD'',sysdate,sysdate);' as Script FROM PROJ where Name like '%[Param.1]%'

union

SELECT 11 as ColOrder,' INSERT INTO PROJMOD VALUES(' || ID || ',' || ProjID || ',' || ModID || ',' || ObjID || ',sysdate);' as Script FROM PROJMOD where ProjID in ( select ID from PROJ where Name like '%[Param.1]%')

) x

Order by ColOrder

但它给了我ORA-12704:字符集不匹配错误.

当我单独运行select语句时,它给了我正确的输出,但是当我同时选择两个select时,它会给出tme字符集不匹配错误.

这可能有什么问题?

因为你已经确认了一些东西是NVARchar的…将nvarchar转换为char例如
sql> create table tab(a nvarchar2(2));

Table created.

sql> insert into tab values ('a');

1 row created.

sql> select 1,'hi' from dual
  2  union all
  3  select 2,a from tab;
select 1,'hi' from dual
          *
ERROR at line 1:
ORA-12704: character set mismatch

失败,因为“A”是NVARCHAR.所以to_char它:

sql> select 1,to_char(a) from tab;

         1 'HI'
---------- ----
         1 hi
         2 a

或者将字符串文字’hi’强制转换为Nvarchar

sql> select 1,n'hi' from dual
      2  union all
      3  select 2,a from tab;

             1 N'
    ---------- --
             1 hi
             2 a
原文链接:https://www.f2er.com/oracle/205241.html

猜你在找的Oracle相关文章