Parsing of fields in output

UDA
Fan

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 Smith
Maria De La Fuente
Able Lopez
3 REPLIES
Enthusiast

Re: Parsing of fields in output

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 use

SEL '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_Name

Hope this helps.

Vinay
Fan

Re: Parsing of fields in output

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?
Enthusiast

Re: Parsing of fields in output

It is possible but may not yield correct results as some names can be real long for instance my name

VInay Kumar Bagare.

Vinay Kumar is my first Name.... huh!

Vinay