Solved

how to insert values containing '&'  into a table

Posted on 2008-06-18
4
666 Views
Last Modified: 2013-12-19
When i try to insert a value with & into a table, like

insert into test_tab (test_field) values ('&test');

Oracle is substituting it before it gets passed to the oracle server. How can i make the insertion successful.

Please, clarify.
0
Comment
Question by:Prashanth_atthaluri
  • 2
4 Comments
 
LVL 73

Assisted Solution

by:sdstuber
sdstuber earned 150 total points
ID: 21812118
in your sql*plus script put

set define off

before your insert lines
0
 

Author Comment

by:Prashanth_atthaluri
ID: 21812143
What to do if am not using SQL*PLUS.
0
 
LVL 22

Accepted Solution

by:
DrSQL earned 350 total points
ID: 21812211
Prashanth_atthaluri,
     I'm not sure what tool you are using.  The '&' substitution is a SQL*Plus convention, not an Oracle-wide one.  Most other tools (like Toad) have an escape character (like the "\").  You can also use the chr function to get an ampersand:

insert into test_tab (test_field) values (chr(38)||'test');

The '&' is an ascii 38.  The double bars are the concatenation characters.

Good luck!
DrSQL
0
 

Author Closing Comment

by:Prashanth_atthaluri
ID: 31468306
Thank You both for the solution.
If I have offended any one of you by splitting the points, I am sorry.
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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

708 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

19 Experts available now in Live!

Get 1:1 Help Now