MikeTWebb
MikeTWebb

Reputation: 9279

Oracle special characters

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?

Upvotes: 3

Views: 1642

Answers (3)

Adam Butler
Adam Butler

Reputation: 3037

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');

Upvotes: 4

OMG Ponies
OMG Ponies

Reputation: 332521

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

SET DEFINE OFF

Upvotes: 9

Michael Pakhantsov
Michael Pakhantsov

Reputation: 25370

I assume you use sqlplus, so execute before

set scan off

Upvotes: 0

Related Questions