× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ah, yes, the "update a substring" problem.

You can do a lot of things with SUBSTR, but you can't update a portion of a
field using SUBSTR.  The trick is to update the target field using a
concatenation of the part BEFORE the substring, the new value, and then the
part AFTER the substring.

So, in your case, it would be:

UPDATE FILEA
  SET FIELD2 = SUBSTR(FIELD2,1,88) || 'XX' || SUBSTR(FIELD2,91,153)
  WHERE SUBSTR(FIELD1,1,3) = 'TRD' AND SUBSTR(FIELD2,89,2) = 'AA'

The set combines the first 88 characters of FIELD2, the literal XX, and the
last 153 characters of FIELD2, and puts the whole mess back into FIELD2.
Use this template whenever you need to do a partial update of a field.

Joe


From: Rowe, Sheri

I need to write a 'quick' interactive SQL statement to update a file
based on the conditional field being a substring and the result field
being a substring.

FileA

Field1 (7,A)   position 1,3 contains many values, but I need only 'TRD'
records and position 4-7 contains a customer number value  e.g.
TRD1100, TRD5555, TRD6789 etc

Field2 (243,A)  contains many values, but I need to extract positions
89-90

I need to update all Field1 'TRD' records where field2 position 89-90 =
'AA' to be value 'XX'



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.