Home » RDBMS Server » Server Administration » '&' character in update query
'&' character in update query [message #374867] Mon, 09 July 2001 04:03 Go to next message
Konstantin
Messages: 6
Registered: June 2001
Junior Member
I run the following query:

update const_db set pc_nameofplace_1='straub clinic & hospital' where pc_nameofplace_1 like 'straub cl%';

But instead of setting this field to 'straub clinic & hospital' it sets 'straub clinic hospital'. How can I fix it?

Thanks in advance.
Re: '&' character in update query [message #374869 is a reply to message #374867] Mon, 09 July 2001 05:48 Go to previous messageGo to next message
GIRIDHAR KODAKALLA
Messages: 92
Registered: May 2001
Member
HAI Konstantin,
Try in this way
update const_db set pc_nameofplace_1='straub clinic ' || '&' || ' hospital' where
pc_nameofplace_1 like 'straub cl%';

Cheers,
Giridhar Kodakalla
Re: '&' character in update query [message #374875 is a reply to message #374867] Mon, 09 July 2001 10:10 Go to previous messageGo to next message
cl
Messages: 10
Registered: April 2001
Junior Member
SQL> SET ESCAPE ON

SQL> update const_db
SQL> set pc_nameofplace_1='straub clinic \& hospital'
SQL> where pc_nameofplace_1 like 'straub cl%';

OR

if ESCAPE is set off(by default most systems SET ESCAPE OFF....to see all default setting type:
SQL> show all ), then do this:

SQL> update const_db
SQL> set pc_nameofplace_1='straub clinic \& hospital' ESCAPE '\'
SQL> where pc_nameofplace_1 like 'straub cl%';

Either method should work.
Re: '&' character in update query [message #374902 is a reply to message #374867] Tue, 10 July 2001 12:51 Go to previous message
Kurt Berry
Messages: 3
Registered: July 2001
Junior Member
I have always found it easier to use the CHR() function to translate the character I needed to add when that particular character was a key part of the syntax, especially when I go back and look at the code later and try to figure out what I coded and why. For example:

update const_db set pc_nameofplace_1='straub clinic ' || CHR(38) || ' hospital' where
pc_nameofplace_1 like 'straub cl%';

Maybe not the perfect solution, but it works.
Previous Topic: Re: SQL+ Printing
Next Topic: Object privileges
Goto Forum:
  


Current Time: Wed Jul 03 02:08:33 CDT 2024