现在的位置: 首页 > 综合 > 正文

Oracle字符串如何连接单引号

2012年03月21日 ⁄ 综合 ⁄ 共 463字 ⁄ 字号 评论关闭

 

今天写了个存储过程,需要在字符串变量前后加单引号。貌似简单的事情折腾了我一下午,好在天无绝人之路。终于被我弄明白甲骨文的变态规则。

 

 

Oracle
字符串连接单引号:

 

1.      
首尾单引号为字符串识别标识,不做转译用

2.      
首尾单引号里面如果出现的单引号,并且有多个,则相连两个单引号转译为一个字符串单引号

3.      
单引号一定成对出现,否者这个字符串出错,因为字符串不知道哪个单引号负责结束。

 

  

select to_char('aaa')from dual;
select
'' || to_char('aaa') ||
''from dual;
select
'''' || to_char('aaa') ||
'''' from dual;
select
'''''' || to_char('aaa') ||
'''''' from dual;
select
'''''''' || to_char('aaa') ||
'''''''' from dual;
select
' '' ' ||' ' ||
' '' ' || to_char('aaa') ||
' '' '' ' from dual;

抱歉!评论已关闭.