分类: Oracle
2015-03-20 01:57:06
另外Oracle还提供了一个Q-quote的表达式,来简化SQL或PLSQL中字符串的表示,其格式为q'[Camera's category is Photo]',输出为方括号中的原始字符串格式,其中方括号可以更换为其他的任意一对特殊符号,但必须是成对出现的,不可为q'[Camera's category is Photo|'。
如:
SQL> select q'[Camera's category is Photo]' name from dual;
NAME
--------------------------
Camera's category is Photo
SQL> select q'|Camera's category is 'Photo'|' name from dual;
NAME
----------------------------
Camera's category is 'Photo'
A:错误, is后面应该是两个单引号,正确的为
SELECT prod_name || q'''s category is ''|| prod_category CATEGORIES
FROM products;
B:错误,category 前面少了一个',正确的为
SELECT prod_name || q'['s ]'||'category is '||prod_category CATEGORIES FROM products;