• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

inserting character strings

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic