All Forums UDA
js6465 2 posts Joined 06/06
22 Jun 2006
Parsing of fields in output

I have a question regarding the parsing of fields in output. For example, if my table has a field called Full_Name, and I want the output to be in First_Name and Last_Name, how could that be done? My problem is the variable length of names and the names that include extra spaces.I am trying to use the SUBSTR, is this even possible?Some examples of names in the table:J R SmithMaria De La FuenteAble Lopez

BBR2 96 posts Joined 12/04
22 Jun 2006

This may be possible if the First and last name are separated by Comma (or something other than a space.)assuming that it is a "," separated field, you could useSEL 'Bagare, Vinay' AS Str,TRIM(SUBSTRING(STR FROM 1 FOR (POSITION(',' IN STR) - 1))) AS Last_Name,TRIM(SUBSTRING(STR FROM (POSITION(',' IN STR)+1) FOR CHARACTER_LENGTH(Str))) AS First_NameHope this helps.Vinay

js6465 2 posts Joined 06/06
22 Jun 2006

Unfortunately it is not seperated by a comma but by a Space. Is there a way to code it to account for the space like you have done for a comma?

BBR2 96 posts Joined 12/04
22 Jun 2006

It is possible but may not yield correct results as some names can be real long for instance my nameVInay Kumar Bagare.Vinay Kumar is my first Name.... huh! Vinay

You must sign in to leave a comment.