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

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'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值