Solved

Disable special character & in Oracle sql statement

Posted on 2009-04-02
3
951 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
ID: 24051508
SQL> set define off

then run your query





0
 
LVL 17

Assisted Solution

by:k_murli_krishna
k_murli_krishna earned 300 total points
ID: 24052149
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
ID: 24052185
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

832 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