Solved

Disable special character & in Oracle sql statement

Posted on 2009-04-02
3
950 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

Suggested Solutions

Title # Comments Views Activity
PL/SQL LOOP CURSOR 3 58
What is the version of ojdbc6.jar 2 39
Oracle query output question 4 36
PL/SQL Display based on value 4 19
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…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

920 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

12 Experts available now in Live!

Get 1:1 Help Now