Oracle special characters

一世执手 提交于 2019-12-13 14:21:40

问题


I have a query

select * from table where name in ('52 T&M', '60 T&M');

The "&" is causing the query to expect a parameter. How do I qualify the "&" in the query to sting so that the query can find string with the "&" character in them?


回答1:


I would normally use set define off as suggested by omg but it is also possible to do it like this:

select *
from table
where name in ('52 T'||Chr(38)||'M', '60 T'||Chr(38)||'M');



回答2:


The ampersand ("&") is a character interpreted by SQLPlus as a variable placeholder. Use:

SET DEFINE OFF



回答3:


I assume you use sqlplus, so execute before

set scan off



来源:https://stackoverflow.com/questions/3669711/oracle-special-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!