If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Simple SQL semi colon problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-03-04, 22:32
reddevil reddevil is offline
Registered User
 
Join Date: Aug 2004
Posts: 6
Question Simple SQL semi colon problem

Hi,
I am trying to insert values into my database using the command window (im running DB2 version 8.1), but when my insert statement hits a semi colon (";") it considers that the terminating point

How can i insert data into my database when the values themselves contain semi colons?? Is there an escape code or something??
E.g.
insert into "~TMPCLP361431" values ('document 1','bla bla bla; bla bla bla');

Your help is much appreciated
Reply With Quote
  #2 (permalink)  
Old 08-04-04, 00:06
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
What is the datatype of the field ? I tried with char and varhcar, its working fine.
Reply With Quote
  #3 (permalink)  
Old 08-04-04, 00:09
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
Sorry, previuosly I tried using JDBC and it worked. When I tried through DB2 command rpompt, its not working.
Reply With Quote
  #4 (permalink)  
Old 08-04-04, 00:12
SamCute SamCute is offline
Registered User
 
Join Date: Mar 2004
Posts: 205
Try this working fine :

db2 insert into testchar1 values\(\'fgfg\;fdsg\'\)

Escape sequence is '\'
Reply With Quote
  #5 (permalink)  
Old 08-04-04, 00:35
reddevil reddevil is offline
Registered User
 
Join Date: Aug 2004
Posts: 6
Red face

Quote:
Originally Posted by SamCute
Try this working fine :

db2 insert into testchar1 values\(\'fgfg\;fdsg\'\)

Escape sequence is '\'
Hey,

Thanks for your help, i tried this through the command window and it does not work, it still will not allow the ";" as part of the string. Its still interprets it as the end of the SQL insert. Im not sure what else to try . How does the escape character work?? And does it work in the command window??
Reply With Quote
  #6 (permalink)  
Old 08-04-04, 00:38
reddevil reddevil is offline
Registered User
 
Join Date: Aug 2004
Posts: 6
Wink

Sorry, i am using the command center, so im trying to get this to work via the GUI. Cheers Please HELP!!!

Last edited by reddevil; 08-04-04 at 17:13. Reason: Update
Reply With Quote
  #7 (permalink)  
Old 08-04-04, 19:07
reddevil reddevil is offline
Registered User
 
Join Date: Aug 2004
Posts: 6
Thumbs up

Hey Everyone,
Ive finally solved my own problem. Just thought id post it to let others know. Turned out to be really simple!!

e.g.
insert into "~TMPCLP361431" values ('document 1','bla bla bla; bla bla bla');
in the command center stops at the ";"

instead use:
insert into "~TMPCLP361431" values ('document 1','bla bla bla'||CHR(59) ||'bla bla bla');

Thanks for your help Sam, its much appreciated.
Reply With Quote
  #8 (permalink)  
Old 08-05-04, 09:27
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You might also try changing the Termination character from a semicolon (the default) to something else (e.g.'@'). This can be done on the Tools -> Tool Settings dialog.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On