wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes inserting character strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "inserting character strings" Watch "inserting character strings" New topic

inserting character strings

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68

I have to insert the following text containing special characters in oracle.can anyone help me on writing this query

The text to insert is "/action/forwardfwdPage=fwdItem&program=item&clearCache=yes"

Thanks in Advance,
Best Regards,
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41096
Um, which characters do you consider special? They all seem to be ASCII, so no database should have problems with them.

Ping & DNS - my free Android networking tools app
siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
Dear Ulf,

SQL> insert into test values('
2 /action/forwardfwdPage=fwdItem&program=item&clearCache=yes');
Enter value for program:
Enter value for clearcache:
old 2: /action/forwardfwdPage=fwdItem&program=item&clearCache=yes')
new 2: /action/forwardfwdPage=fwdItem=item=yes')

1 row created.

SQL> select * from test;


As shown above,i executed the query and the i got the result as shown.But in the result the special characters ?,& are not getting inserted.
Please look into this.

Thanks in ADvance,
Best Regards,
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Hi Siva & Ulf,

This is not a character set problem.

An ampersand (&) is a special character in Oracle and is interpreted as the beginning of a variable name.

To prevent this interpretation of the ampersand, it must be at the end of a string. Thus, to handle the insert shown above properly, do the following:

SQL> insert into test values ('2 /action/forwardfwdPage=fwdItem&'||'program=item&'||'clearCache=yes');

1 row created.

SQL> select * from test;

2 /action/forwardfwdPage=fwdItem&program=item&clearCache=yes
Chris Hendy
Ranch Hand

Joined: Mar 04, 2006
Posts: 98
As long as it is in SQL*PLUS you can also do the following:

SQL> set define off
SQL> insert into test values('/action/forwardfwdPage=fwdItem&program=item&clearCache=yes');

1 row created.

SQL> select * from test;


SQL> set define on
wood burning stoves
subject: inserting character strings
Similar Threads
handle special characters from text area using
Game on SQL
How to handle comma in the text field?
Oracle 10g Clob Datatype Cannot Insert data
Insert a Symbol into a TextArea String