0

I had a table in Oracle database that contains id, name fields.

It's data is:

123,'South'

121,'East'

445,'Africa & World'

When I select rows using where clause like

select * from where name = 'Africa & World';

Oracle Asks for a Substitution Variable and no records are returned.

Kindly tell me to further clarify my question.

Regards

3 Answers 3

4

The problem is that & is reserved as a marker for binding variables. You need to escape the & symbol.

You can escape the ampersand by

SET ESCAPE ON;
select * from where name = 'Africa \& World';

or you can set the bindings off by

SET DEFINE OFF;
select * from where name = 'Africa & World';
Sign up to request clarification or add additional context in comments.

Comments

2

From http://www.orafaq.com/wiki/SQL_FAQ

Option #1

SET DEFINE ~
SELECT 'Laurel & Hardy' FROM dual;

Option #2

SET ESCAPE '\'
SELECT '\&abc' FROM dual;

Options #3

SET SCAN OFF
SELECT '&ABC' x FROM dual;

Option #4

SELECT 'Laurel ' || '&' || ' Hardy' FROM dual;

Option #5 (Use the 10g Quoting mechanism)

SELECT q'{This is Orafaq's 'quoted' text field}' FROM DUAL;

1 Comment

My preference has always been option #3 SET SCAN OFF
0

This is a SQL*Plus thing.

At the SQL*Plus prompt, type:

SET DEFINE OFF

Then try re-running your statement.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.