how to insert values containing '&' into a table

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.
Who is Participating?
DrSQLConnect With a Mentor Commented:
     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!
sdstuberConnect With a Mentor Commented:
in your sql*plus script put

set define off

before your insert lines
Prashanth_atthaluriAuthor Commented:
What to do if am not using SQL*PLUS.
Prashanth_atthaluriAuthor Commented:
Thank You both for the solution.
If I have offended any one of you by splitting the points, I am sorry.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.