× 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.



Wilt, Charles wrote:
Adam,

Why don't you use Elvis idea?

I'm on v5r2, so I can't use replace, but TRANSLATE works...

select trim(translate(myfield,' ', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',' ')) from myfile

That suggestion gets rid of all the alphabetic characters. Also, I forgot that dashes might be in there as well.

input result of trim+translate desired result
ABP-N42A-43030C3D - 42 -43030 3 42A-43030C3D
ABP-N74B-10801 - 74 -10801 74B-10801
AE1131XMF 1131 1131XMF
AF25033M 25033 25033M
AF25139M 25139 25139M
AF25694 25694 25694
AF364 364 364

FWIW, this SEQUEL query works. SST is substring, LENGTH finds the length of the string, and INDEX is like RPG's check, except that it finds the first position of one of the characters in the list, rather than _not_ in the list. I couldn't find an analogue to INDEX in real SQL. I probably just didn't look hard enough :)

SELECT SST(myfield, INDEX(myfield,'0123456789'),LENGTH(prtnum))

Thanks for all the suggestions,
Adam

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.