row value to be populated in all the fields

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
pandujoy
Participant
Posts: 70
Joined: Tue May 13, 2008 1:37 pm

row value to be populated in all the fields

Post by pandujoy »

Hi Gurus,

I am a bit confused how to do this.. Please share your thoughts...

say i am getting 10 rows from source in which i have a column called row number.

Eg:-

rowno. model customerno. state

01 00 12334 IL
02 02 9876 CA
03 00 98767 LA

Now my requirement is - if in the column "model" when ever i see "02" i have to replace all the rows with "02" instead "00" like


rowno. model customerno. state

01 02 12334 IL
02 02 9876 CA
03 02 98767 LA

or if there is no "02" i have to just bring the "00" value.

How do i do that . Any thought would be appreciated.

Thanks in advance.
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Post by vinnz »

IFF the file really is going to be as small as you mentioned, you might as well pre-process the file using UNIX cut, sort, grep commands to find out if the '02' exists in the model number column in an Execute Command Stage and then pass it down to the job as a parameter in a job sequence.

HTH
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

Hi

I assue the following:

RowNumber -varchar
Model - varchar
Custnum - integer
state varchar2(2)

to convert all null model to '02' you can use a modify stage:
MODEL_NEW=HANDLE_NULL(MODEL, '02')

or if you think that the input is very less and you have a transformer, you can convert all the 00 to 02 and null's to 02. use a 'If Then Else' statement.

If IsNull(MODEL) Then "02" Else If MODEL = "00" Then "02" Else MODEL

I guess this should work.
Thanks
Karthick
pandujoy
Participant
Posts: 70
Joined: Tue May 13, 2008 1:37 pm

Post by pandujoy »

hey thanks for the reply

Infact this is a webservice and the problem is

if i get 10 rows and in which i have 5 rows with "02" and 5 rows with "00" ...so since there is a row coming with "02" i have to change all the column values to "02" instead of "00"...no clue how to solve this :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You'll need to make two passes through the data, once to check for the '02' model and a second time to make the changes if you find one. That check can be a another job or a script as noted, if you've landed the data.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What's your target? If it's something updatable (like a db table) then you could load the data as is and if '02' is detected, issue an update post load.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply