Solved

sql update statement

Posted on 2007-11-27
11
460 Views
Last Modified: 2013-12-18
I need to run this update statement

UPDATE SIEBEL.EIM_ADDR_PER SET AP_COUNTRY = 'Korea, Democratic People's Rep'

the problem comes in with the "People's" the statement recognizes the 's as the end.

Thanks for your help.
0
Comment
Question by:rrisal
  • 2
  • 2
  • 2
  • +3
11 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 168 total points
ID: 20358540
UPDATE SIEBEL.EIM_ADDR_PER SET AP_COUNTRY = 'Korea, Democratic People''s Rep'
0
 

Author Comment

by:rrisal
ID: 20358587
angellll thanks for the suggestion but when i run that the result i get is

Korea, Democratic People''s Rep

The desired result i was looking for was just one quotation

Korea, Democratic People''s Rep

Is there a way to do this? Thanks.
0
 
LVL 19

Assisted Solution

by:erikTsomik
erikTsomik earned 166 total points
ID: 20358599
i AGRRE WITH angelIII. The problem is apostrphies
you can also try something like this I am not sure about syntax but it is something like that
declare @str as varchar;
declare @str2 as varchar;
Set @str='Korea, Democratic People's Rep'
set @str2=replace(@str,"'", "''")
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 20

Expert Comment

by:steelseth12
ID: 20358625
escape character in mysql is backslash (\)

UPDATE SIEBEL.EIM_ADDR_PER SET AP_COUNTRY = 'Korea, Democratic People\'s Rep'

angelIII is in mssql mode :)
0
 
LVL 34

Assisted Solution

by:johnsone
johnsone earned 166 total points
ID: 20358814
In angelIII's response, that is two single quotes, not a double quote.

Escaping a single quote will not work.  You should get a ORA-01756 with steelseth12's query.

The other way to do it is this:

UPDATE SIEBEL.EIM_ADDR_PER SET AP_COUNTRY = 'Korea, Democratic People' || chr(39) || 's Rep'
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20358860
>angelIII is in mssql mode :)
the '' (2 single quotes) will also work in Oracle...  the chr(39) "trick" is not needed, but will work also in oracle.
0
 
LVL 20

Expert Comment

by:Muhammad Wasif
ID: 20358879
You can escape a single quote with another single quote too.
0
 
LVL 20

Expert Comment

by:Muhammad Wasif
ID: 20358887
angelIII already explained it :-)
0
 
LVL 34

Expert Comment

by:johnsone
ID: 20359189
angelIII,

I know the chr(39) trick is not needed and the two single quotes works.  I was just giving another alternate.  I prefer your solution.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now