Solved

Disable special character & in Oracle sql statement

Posted on 2009-04-02
3
948 Views
Last Modified: 2013-12-18
If you issue
SQL> select '&1' from dual;
Enter value for 1: dummy
old   1: select '&1' from dual
new   1: select 'dummy' from dual
dummy
However, I would like to get:
&2
instead of dummy, so disable the special charcter & in this sql statement.
0
Comment
Question by:jl66
  • 2
3 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 200 total points
Comment Utility
SQL> set define off

then run your query





0
 
LVL 17

Assisted Solution

by:k_murli_krishna
k_murli_krishna earned 300 total points
Comment Utility
You can do the following alternative ways as well:
SELECT chr(ascii('&')) || '1' FROM dual;
Try also:
SELECT "&" || '1' FROM dual;

Just like single quote ' is specific escape character for ' i.e. you will use it as:
SELECT 'gain''s' FROM dual;
Back slash (\) is the generic escape character in Oracle.
0
 
LVL 17

Assisted Solution

by:k_murli_krishna
k_murli_krishna earned 300 total points
Comment Utility
You can use REPLACE and TRANSLATE functions to substitute a harmless and unused character in place of & and then substitute back while using the result OR if used in WHERE condition, then compare with constant/literal value also containing substituted character.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now