`
mwei
  • 浏览: 123923 次
  • 性别: Icon_minigender_1
  • 来自: 抽象空间
社区版块
存档分类
最新评论

the type of String literal in oracle_10

    博客分类:
  • db
阅读更多
'北京' 在sql语句中的类型是varchar2;
接下来验证一下:
create table province(name nvarchar2(10)); --name的类型是nvarchar2
insert into province values('天府');
insert into province values('国家首都');
select (CASE  WHEN name LIKE '%首都%' THEN  ('北京')  
     ELSE (name) END) as name from province; --ORA-12704:字符集不匹配

此处确定'北京'这样的字面值不是NVARCHAR2类型的;
TO_CHAR()把NCHAR, NVARCHAR2, CLOB, NCLOB 转换成VARCHAR2类型;
TO_NCHAR()把CHAR, VARCHAR2, CLOB, NCLOB 转换成NVARCHAR2类型;
select (CASE  WHEN name LIKE '%首都%' THEN  ('北京')  
     ELSE to_char(name) END) as name from province; --ok 

这句可以确定'北京'是VARCHAR2类型;
下面这句同样不会报错;
select (CASE  WHEN name LIKE '%首都%' THEN  to_nchar('北京')  
      ELSE (name) END) as name from province; --ok



分享到:
评论

相关推荐

    oracle explain plan总结

    EXPLAIN PLAN [SET STATEMENT_ID [=] <string_literal>] [INTO <table_name>] FOR <sql_statement> ``` 其中: - `STATEMENT_ID` 是一个可选参数,用于标识执行计划。 - `TABLE_NAME` 是存储执行计划信息的目标表...

    unidac_7_1_4_pro DELPHI 10 Tokyo

    Bug with using batch parameters of the Bytes type is fixed Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile ...

    unidac_7_1_4_pro DELPHI 10 Berlin

    Bug with using batch parameters of the Bytes type is fixed Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile ...

    UniDAC 7.1.4

    In the other words, if you upgrade one of the installed providers, it may conflict with older builds of other products. In order to continue using the products simultaneously, you should upgrade all ...

    Unidac Pro 7.1.4 XE8

    Bug with using batch parameters of the Bytes type is fixed Bug with closing a connection that has an active transaction for Firebird 3 is fixed Bug with recreating a connection on Linux and mobile ...

    ORACLEEXPLAINPLAN的总结[文].pdf

    explain PLAN [ SET STATEMENT_ID [=] <string literal>] [INTO <table_name>] FOR <sql_statement> ``` - `STATEMENT_ID` 是一个可选的唯一标识符,用于区分不同的执行计划。 - `TABLE_NAME` 是存放执行计划的表名...

    plan_table学习笔记

    EXPLAIN PLAN [ SET STATEMENT_ID [=] <string literal> ] [ INTO <table_name> ] FOR <sql_statement> ``` 其中,STATEMENT_ID 指定了执行计划的名称,如果不指定,则默认为 NULL。 Plan Table 中的主要列有: *...

    java-helloworld

    在IT行业中,Java是一种广泛应用的面向对象的编程语言,由Sun Microsystems(现为Oracle Corporation的一部分)于1995年发布。"Java HelloWorld"是学习任何编程语言时的传统起点,它是一个简单的程序,用于打印...

    JDK15语言详细说明书

    这份文档的版权归属于Oracle America, Inc.,并且在附录A中对使用许可做出了明确的限定。JDK 15版本最终在2020年9月发布。 2. 语言规范结构 JLS的内容从语言结构到类型系统,再到变量声明和使用,深入浅出地描述了...

    spring-framework-reference4.1.4

    Examples of dependency injection ............................................................. 36 Dependencies and configuration in detail ........................................................... ...

    spring-framework-reference-4.1.2

    Examples of dependency injection ............................................................. 36 Dependencies and configuration in detail ........................................................... ...

Global site tag (gtag.js) - Google Analytics