ocp 047-141 Evaluate the following SQL statement:SELECT product_name || 'it's not available for orde

来源:互联网 发布:node pdf导出 编辑:程序博客网 时间:2024/05/18 22:16

Evaluate the following SQL statement:
SELECT product_name || 'it's not available for order' FROM product_information
WHERE product_status = 'obsolete';
You received the following error while executing the above query:
ERROR:
ORA-01756: quoted string not properly terminated
What would you do to execute the query successfully?

A. Enclose the character literal string in the SELECT clause within the double quotation marks.
B. Do not enclose the character literal string in the SELECT clause within the single quotation marks.
C. Use Quote (q) operator and delimiter to allow the use of single quotation mark in the literal character
string.
D. Use escape character to negate the single quotation mark inside the literal character string in the
SELECT clause.
Answer: C

ORA-01756: quoted string not properly terminated 

错误:引用字符串不正确地终止

错误原因:多为SQL语句问题,要考虑到字符集这方面

所以错误就是在SELECT product_name || 'it's not available for order' 中的引号这块


1.在字符串单引号处再加一个单引号

product_name || 'it's not available for order' --改为product_name || 'it''s not available for order'

如果字符中包括了单引号,就在该单引号处使用两个单引号;如果字符中出现了双引号,就直接在字符中使用双引号。

单引号的作用:加了单引号的字段是一个字,类似字符串,不区分大小写,,单引号是用来特制的,比如日期字符串的

引用,两个单引号就是纯正的单引号,表示转义。

2、使用“q-quote写法”

product_name || 'it's not available for order' --改为product_name || q'<it's not="" available="" for="" order="">'

Use Quote (q) operator and delimiter to allow the use of single quotation mark in the literal character string.


3、使用“chr(39)写法”

product_name || 'it's not available for order' --改为product_name || ‘ it'||chr(39)||'s not available for order'

0 0
原创粉丝点击