+ Reply to Thread
Results 1 to 5 of 5

Thread: V5R2 SQL gotcha with SUBSTR

  1. #1

    Default V5R2 SQL gotcha with SUBSTR

    I'm curious: What is the ANSI standard for SUBSTR? IBM has gone to great lengths to ensure that DB2/400 has a greater degree of ANSI compliance than any other RDBMS. Dave

  2. #2
    Guest.Visitor Guest

    Default V5R2 SQL gotcha with SUBSTR

    Ken Rokos wrote: > In V5R2, the SUBSTR function no longer returns an error if the offset > and/or length are out of range. For example, let's say file X has > field Y which is 5 characters long. This will not fail in V5R2: > > select substr(y,20,30) from x > > It'll successfully return a 30-character blank value instead. I don't know if I'd call this a Gotcha. I'd put this in the same category as returning a zero result when a calculation divides by zero. bill

  3. #3
    Guest.Visitor Guest

    Default V5R2 SQL gotcha with SUBSTR

    It's different than it has always been before. It is something that can catch the unwary. It's as if dividing by zero used to always cause an MCH error that you could monitor, and now it succeeds and returns zero. It's not what you'd expect or be used to.

  4. #4
    Guest.Visitor Guest

    Default V5R2 SQL gotcha with SUBSTR

    In V5R2, the SUBSTR function no longer returns an error if the offset and/or length are out of range. For example, let's say file X has field Y which is 5 characters long. This will not fail in V5R2: select substr(y,20,30) from x It'll successfully return a 30-character blank value instead. This also affects 3rd-party products like SEQUEL from ASC. The SUBSTR function in QUERY/400 still gives errors if you try out-of-range values.

  5. #5
    Guest.Visitor Guest

    Default V5R2 SQL gotcha with SUBSTR

    By the way, SUBSTR and SUBSTRING are actually different functions and can return different results, especially with DBCS and with this out-of-bounds behavior.

+ Reply to Thread

Similar Threads

  1. SQL and substr
    By dacust in forum SQL
    Replies: 4
    Last Post: 01-21-2004, 04:52 AM
  2. Packed Vs Signed Gotcha
    By Guest.Visitor in forum RPG
    Replies: 5
    Last Post: 02-04-2002, 06:59 AM
  3. Updating a file using SUBSTR
    By Guest.Visitor in forum Programming
    Replies: 3
    Last Post: 08-29-2001, 10:38 AM
  4. using substr with imbedded field doesn't work with qm
    By Guest.Visitor in forum Programming
    Replies: 5
    Last Post: 07-20-2001, 09:27 AM
  5. FMTCLSRC Gotcha
    By daly.michael@verizon.net in forum Application Software
    Replies: 1
    Last Post: 01-23-1999, 08:07 AM

Posting Permissions

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