dbTalk Databases Forums  

INSERT with a apostrophe in a string

comp.databases.postgresql comp.databases.postgresql


Discuss INSERT with a apostrophe in a string in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
N.G.
 
Posts: n/a

Default INSERT with a apostrophe in a string - 03-25-2009 , 03:02 AM






Hi,

i got a following problem,
the sql query is:

INSERT INTO
struktur(pordnr,bed,satznr,katalognr,vgl,anz,art,l ogik,funktionen,xkoord,ykoord,verknop)
('8139','G','113','-2','M','1','A',')!','gewicht:UB;sql:me.labnr;setze _erw:LAB.pnote='',
LAB.bonus=''','9','1','o'),
('8139','G','104','-2','G','1','A','/','gewicht:UB;sql:me.labnr;setze_erw:LAB.pstatus=' EN',
LAB.bonus='', LAB.pnote='500'','1','2','')


the problem is here in this part:
'gewicht:UB;sql:me.labnr;setze_erw:LAB.pstatus='EN ', LAB.bonus=''

this is one string which is supposed to belong to funktionen.

the parser gets crazy at this point
'gewicht:UB;sql:me.labnr;setze_erw:LAB.pstatus='E

Now my question is there some special command which allows me to insert
a string which contains one or more apostrophe ?

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: INSERT with a apostrophe in a string - 03-25-2009 , 03:22 AM






N.G., 25.03.2009 10:02:
Quote:
the parser gets crazy at this point
'gewicht:UB;sql:me.labnr;setze_erw:LAB.pstatus='E

Now my question is there some special command which allows me to insert
a string which contains one or more apostrophe ?

In Postgres it's like in any other (standard compliant) database, simply put two single quotes in there:

INSERT INTO my_table
(some_data)
VALUES ('With '' single quote');

In your case this would be:

'gewicht:UB;sql:me.labnr;setze_erw:LAB.pnote='''', LAB.bonus='''' '

(I added a space before the "closing" quote to make clear where the actual value ends)

Thomas


Reply With Quote
  #3  
Old   
N.G.
 
Posts: n/a

Default Re: INSERT with a apostrophe in a string - 03-25-2009 , 04:16 AM



Thomas Kellerer schrieb:
Quote:
N.G., 25.03.2009 10:02:
the parser gets crazy at this point
'gewicht:UB;sql:me.labnr;setze_erw:LAB.pstatus='E

Now my question is there some special command which allows me to
insert a string which contains one or more apostrophe ?


In Postgres it's like in any other (standard compliant) database, simply
put two single quotes in there:

INSERT INTO my_table (some_data)
VALUES ('With '' single quote');

In your case this would be:

'gewicht:UB;sql:me.labnr;setze_erw:LAB.pnote='''', LAB.bonus='''' '

(I added a space before the "closing" quote to make clear where the
actual value ends)

Thomas
thank you thomas for the quick answer,

you were right i just got to less '


Nico


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.