Comparing stage variables in transformer

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
prasad_chennai
Participant
Posts: 38
Joined: Wed Jul 18, 2007 12:23 am
Location: Chennai

Comparing stage variables in transformer

Post by prasad_chennai »

I have a parallel job which gets its data from a Exec command in Sequence job.
The output of the Exec cmd (lets say A) is appended to the data in the
text file. Delimiter is | . The text file can have 2 records. So A is
appended at the end of both the records.
The Sequence file in the parallel job will be reading 5 files based on pattern and A
will be different in each file.

I need to use a transformer compulsory to see that the A is not
repeated more than once. (Sample data of A = Nov 16 08:24)

The steps I did:
I defined A column as varchar in Sequence file.
In transformer: right(A,1)= d (stage var)
if d = c then 'Y else 'N' = b (stage variable)
d = c (stage variable)

Constraints: b='N'

I not able to get the right output. It is taking all records as
unique. I can see the data in A column. When I say A = c, it is
assigning the value to c but it is not able to compare the data. I am
able to see the data present in c in the output.

If I hardcoded the comparison value then I am able to see the right output.
Eg. if in transformer: i give : if d='4' then 'Y' else 'N'
(if last char in the string is 4)

I am not sure why it is not comparing d & c.

d&c are defined as varchar. If I give AsInteger(right(A,1)) , it shows
transformer error while compiling. Since A is the output from Unix cmd
will there be any different datatype for that?
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

If you have doubt on-
Since A is the output from Unix cmd
will there be any different datatype for that?
Then you can apply the below on the execute command output

Code: Select all

Trim(Convert(@FM,"",ExecuteCommand1.CommandOutput))
Or

Code: Select all

tr -d '\n'

Please let me know if it is not helpfull.
Post Reply