Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Unanswered: 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?

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •