'北京' 在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
分享到:
相关推荐
EXPLAIN PLAN [SET STATEMENT_ID [=] <string_literal>] [INTO <table_name>] FOR <sql_statement> ``` 其中: - `STATEMENT_ID` 是一个可选参数,用于标识执行计划。 - `TABLE_NAME` 是存储执行计划信息的目标表...
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 ...
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 ...
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 ...
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 ...
explain PLAN [ SET STATEMENT_ID [=] <string literal>] [INTO <table_name>] FOR <sql_statement> ``` - `STATEMENT_ID` 是一个可选的唯一标识符,用于区分不同的执行计划。 - `TABLE_NAME` 是存放执行计划的表名...
EXPLAIN PLAN [ SET STATEMENT_ID [=] <string literal> ] [ INTO <table_name> ] FOR <sql_statement> ``` 其中,STATEMENT_ID 指定了执行计划的名称,如果不指定,则默认为 NULL。 Plan Table 中的主要列有: *...
在IT行业中,Java是一种广泛应用的面向对象的编程语言,由Sun Microsystems(现为Oracle Corporation的一部分)于1995年发布。"Java HelloWorld"是学习任何编程语言时的传统起点,它是一个简单的程序,用于打印...
这份文档的版权归属于Oracle America, Inc.,并且在附录A中对使用许可做出了明确的限定。JDK 15版本最终在2020年9月发布。 2. 语言规范结构 JLS的内容从语言结构到类型系统,再到变量声明和使用,深入浅出地描述了...
Examples of dependency injection ............................................................. 36 Dependencies and configuration in detail ........................................................... ...
Examples of dependency injection ............................................................. 36 Dependencies and configuration in detail ........................................................... ...