All Forums Database
nagendratrpth 25 posts Joined 03/14
28 May 2015
Finding last character of a string

Do we have some different approch to get last character of a string ( Fix length/ Variable length both ) apart from using substr ?

Tuen 44 posts Joined 07/05
28 May 2015

Substr is really about the only function that lets you pull a single value out, especially depending on what version of the database you are on.  I guess you could build a UDF that might do something, but if you have a native feature that can do the job, why not use it.   using a combination of trim, character_length, position, and substr you can pretty much do what you want.  There isn't a feature/function that I am aware of that will let you get the last character of a string at least natively in the database.
If your on 14.10 or 15.00 you might try strtok which can parse a string, but not sure if it can parse things like a word or not (never tried it).
Is there a reason you don't want to use substr?

You must sign in to leave a comment.