• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 467
  • Last Modified:

sql update statement

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
rrisal
Asked:
rrisal
  • 2
  • 2
  • 2
  • +3
3 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
UPDATE SIEBEL.EIM_ADDR_PER SET AP_COUNTRY = 'Korea, Democratic People''s Rep'
0
 
rrisalAuthor Commented:
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
 
erikTsomikSystem Architect, CF programmer Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
steelseth12Commented:
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
 
johnsoneSenior Oracle DBACommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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
 
Muhammad WasifCommented:
You can escape a single quote with another single quote too.
0
 
Muhammad WasifCommented:
angelIII already explained it :-)
0
 
johnsoneSenior Oracle DBACommented:
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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now