日期:2014-05-17  浏览次数:21007 次

求助,关于输出"’"的问题.
需要输出的语句为Envoy Ambassador's category is Hardware;
有4个选项,
A. SELECT prod_name || q'''s category is ' || prod_category CATEGORIES
FROM products;
B. SELECT prod_name || q'['s ]'category is ' || prod_category CATEGORIES
FROM products;
C. SELECT prod_name || q'\'s\' || ' category is ' || prod_category CATEGORIES
FROM products;
D. SELECT prod_name || q'<'s >' || 'category is ' || prod_category CATEGORIES
FROM products;

D选项测试过了,是对的,C选项对不对?为什么我测试的是不对的呢,但是答案是CD.
求高手指教,谢谢

------解决方案--------------------
SQL code
SQL> SELECT  q'<'s >' from dual;

Q'<
---
's

SQL> SELECT  q'\'s \' from dual;

Q'\
---
's

SQL> SELECT  q'['s ]' from dual;

Q'[
---
's
就是一个转义字符一样的了

------解决方案--------------------
oracle里面转义的方法有很多 不过一般要显示单引号 可以这么用 不用转义

SQL code


select 'Ambassador'||chr(39)||'s' c1
from dual