Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting character strings

 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


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,
Siva
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, which characters do you consider special? They all seem to be ASCII, so no database should have problems with them.
 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;


VAL
--------------------------------------------------
/action/forwardfwdPage=fwdItem=item=yes



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,
Siva
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

VAL
--------------------------------------------------------------------------------
2 /action/forwardfwdPage=fwdItem&program=item&clearCache=yes
 
Chris Hendy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;

COL1
--------------------------------------------------------------------------------
/action/forwardfwdPage=fwdItem&program=item&clearCache=yes

SQL> set define on
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic