FIELD function

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

FIELD function

Post by sam334 »

All, need a quick help on field function.

I have a name- ASHLEY, MARTHA ANNIE

This is char(30) column and need to separate it to first name,last name and middle name, three separate column. Used FIELD function below.

LAST NAME- FIELD(name,',','1')

Last name worked. But got stuck in first and middle name.
It should be,
Last name- ASHLEY
First Name-MARTHA
Middle name-ANNIE

Appreciate your help.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... the second comma delimited field is First and Middle. Pull that and then use Field again on that telling it is a space delimited string: 1=First and 2+=Middle. Now that won't always work but it should get you close enough so you can then identify the outliers.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is a case where I'd use stage variables to avoid unnecessary processing (in particular splitting the comma-delimited string more than once). For example:

Code: Select all

svFamilyName  <--  Field(InLink.FullName, ",", 1, 1)
svGivenNames  <--  Field(InLink.FullName, ",", 2, 1)
svFirstName  <--  Field(svGivenNames, " ", 1, 1)
svMiddleName <--  Field(svGivenNames, " ", 2, 9)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thought that went without saying. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

One of the services I perform is a DataStage health check. You would be surprised how many functions are unnecessarily multiply evaluated.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Worked well. I was stuck with the outliers. Solved now. Thanks a lot Craig and Ray. Appreciate your help.
Post Reply