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 > Update query using substr

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-08-04, 06:46
Karl1974 Karl1974 is offline
Registered User
 
Join Date: Oct 2004
Posts: 1
Update query using substr

Hi,

I'm using DB2 Version 7 Release 2 on an IBM Mainframe. I'd like assistance with an update query if anyone can help. Thanks in advance.

I need to update the last 4 bytes of a string with value ' ' where the current value of the same portion of the field is '0011'

UPDATE TEST.TABLE
SET CODE_TYPE = (SUBSTR(CODE_TYPE,1,16),' ')
WHERE SUBSTR(CODE_TYPE,17,4) = '00 '

This is the nearest I've got to it, and I know it doesn't work. DB2 really isn't my thing. Can anyone help out?
Reply With Quote
  #2 (permalink)  
Old 10-08-04, 08:16
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
If I understand right,

set code_type=left(code_type,16)||REPEAT(' ',4)

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 10-08-04, 08:40
Helle Helle is offline
Registered User
 
Join Date: Oct 2004
Posts: 3
Well, you beat me by just a couple of minutes....

I would have suggested something like

SET CODE_TYPE = CONCAT (SUBSTR(CODE_TYPE,1,16),' ')
WHERE SUBSTR(CODE_TYPE,17,4) = '0011'

Helle
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