I have a program which accepts inputs from the user on the screen.Accordingly it would display.
Problem - User enters CHRIS(only accepts capital). When user hits enter it is displaying insured name starting with CHRIS only. Though database is having both CHRIS and Chris. Is there any built-in-functions to trap both CHRIS and Chris and that too sequentially.Means - Chris Smith should appear befor CHRIS William.
Appreciate your help.
Thanks & Regards
Chinmoy Dasgupta
Software/Hardware used:
OS400, V6R1M0
ASKED:
July 17, 2012 9:32 AM
This article from this website answers your question nicely:
http://www.itjungle.com/mgo/mgo121203-story01.html
…database is having both CHRIS and Chris. Is there any built-in-functions to trap both CHRIS and Chris…
There are multiple possibilities for that.
… and that too sequentially.
But that restricts the possibilities a little. Best might be to FETCH through a cursor that uses a WHERE clause based on something like this:
WHERE SUBSTR(UPPER( name ),1,length(trim(‘CHRIS’)))=TRIM(‘CHRIS’)
You wouldn’t actually use ‘CHRIS’ in the SQL. Use a host variable. For ‘name’, use the column that holds the name value. And use an ORDER BY clause to control sequencing.
A different ‘best’ way would be to use a LIKE predicate, but a lot of people have trouble with variable length patterns.
Tom
Tom