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 > Updating Varchar data with newline character

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-11, 21:03
dbsam dbsam is offline
Registered User
 
Join Date: Dec 2009
Posts: 31
Updating Varchar data with newline character

Hi Guys,

I am trying to insert a line-break in a string data that I have in varchar column but it is not working. My database is on db2 9.7 on AIX. I tried CHR(10), CHR(13) and the combination of both. I also tried CHAR instead of CHR that works neither. Could you take a look at the update statement and let me know where I am going wrong
Below is my update statement
update db2inst1.risk_tbl set risk =
'ACK-1|01 12|P ' || CHR(10) ||
'PNW-7|09 08|P' || CHR(10) ||
'PNWPR-8|09 08|P' || CHR(10) ||
'HW 00 24|09 08|E'
where id='2010';

Really chr(10) should be the one but why is it not working?

Thanks

dbsam
Reply With Quote
  #2 (permalink)  
Old 12-06-11, 21:57
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
...it is not working.
What do you mean by "not working"?

Got error in the update statement?
So, copy and paste the error message(s).

The result was not expected?
How did you checked it?
Write your expected result and the result you got.
Reply With Quote
  #3 (permalink)  
Old 12-06-11, 23:54
stiruvee stiruvee is offline
Registered User
 
Join Date: May 2010
Location: India
Posts: 34
Try using CHR(13) || CHR(10) instead of CHR(10) alone. In Unix chr(10) is new line and windows and other systems use CHR(13) || CHR(10) for new line.


Satya...
Reply With Quote
  #4 (permalink)  
Old 12-07-11, 08:21
dbsam dbsam is offline
Registered User
 
Join Date: Dec 2009
Posts: 31
Hi Satya/Tonkuma,

I have tried the combination of both, the update command runs successfully every-time but when the application team tries to run the cycle it fails. The application reads the next line character based upon which I can say that the rest of the data is not going to the next line.
Also when I run the select in data studio it does not show me newline character, which it does for all other data.

Thanks

dbsam
Reply With Quote
  #5 (permalink)  
Old 12-07-11, 08:21
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
A newline character is CHR(10). CHR(13) is carriage return. So a CHR(10) is sufficient.

The real question was raised by tonkuma: what exactly is the problem? Maybe it is just the client that can't handle the line break correctly?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 12-08-11, 10:21
dbsam dbsam is offline
Registered User
 
Join Date: Dec 2009
Posts: 31
ok so the CHR(10) was working all along the issue was a hex character that was there in the data. Thanks for the help guys
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