Oracle字符串如何连接单引号


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

 

 

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;

猜你喜欢

转载自churuozhiye-java.iteye.com/blog/1672206