Comparing data in the columns

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Comparing data in the columns

Post by sandeepgs »

Hi,

I have an issue with the data comparison

Totally I have 30 columns. Data in all the fields should be unique.

I tried to achieve this using transformer

ex:

Trim(DSLink6.ACC_NBR) <> (Trim(DSLink6.BAL_AMT) Or Trim(DSLink6.BAL_EFF_DATE) Or Trim(DSLink6.BAL_END_DT) Or Trim(DSLink6.WTHD_AMT))

I cannot effort to have separate not equal conditions. so I combined everything. But the logic i had written is not working. It is passing all the records even if there is matching values.

Is there any other way of achieving this condition.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Observe carefully...U have compared just the First column with the rest...where u checking the in-between cols with each other!
Rgds,
MB
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

mdbatra wrote:Observe carefully...U have compared just the First column with the rest...where u checking the in-between cols with each other!
S actually I noticed it but how can i achieve it. If I go for multiple not equal conditions the querry will become huge. So is there any other Idea of achieving this.

Is there any built in function available for achieving this.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Make stage variable for every column & write its derivation as Trim(col_name) or whatever u need.

Now in output col derivation, compare the input_col with all the stage variables except the one defined for that particular column itself.
Rgds,
MB
devesh_ssingh
Participant
Posts: 148
Joined: Thu Apr 10, 2008 12:47 am

Post by devesh_ssingh »

easiest logic when you are comapring columns,

Creat Two stage variable

SVPrev
SVcur

assigned SVcur to SVprev and
now,in SVcur concat all the coulmns which you want to compare
then
set Svflag= if SVPrev<>SVcur then T else F

in this way you will be able to compare all the columns at a time.
then on flag gettin set on TRUE or FALSE you can do further events.

Hope it will help you!!!

cheers!!!
Devesh
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Devesh..u r concatenating all cols...
Are all the cols having same datatype?
Rgds,
MB
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

(Original post retracted - I misread and misunderstood the question)

Are all the columns numeric of the same type?
Last edited by ArndW on Fri Oct 31, 2008 5:27 am, edited 1 time in total.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

devesh..if u observe carefully, ur logic will compare records( previous & current) & not the columns ..
Rgds,
MB
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

mdbatra wrote:Devesh..u r concatenating all cols...
Are all the cols having same datatype?
S all the columns are of same data type (Char).
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

mdbatra wrote:Devesh..u r concatenating all cols...
Are all the cols having same datatype?
S all the columns are of same data type (Char).
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

even if they are same type, concatenation is not the solution. U would ultimately result into
1. Record Comparison(instead of column)
2. Faulty results( as stated by ArnDW)
Rgds,
MB
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

devesh_ssingh wrote:easiest logic when you are comapring columns,

Creat Two stage variable

SVPrev
SVcur

assigned SVcur to SVprev and
now,in SVcur concat all the coulmns which you want to compare
then
set Svflag= if SVPrev<>SVcur then T else F

in this way you will be able to compare all the columns at a time.
then on flag gettin set on TRUE or FALSE you can do further events.

Hope it will help you!!!

cheers!!!
Devesh
Hi Devesh,

As per my undrestanding. IT goes this way

Ex:
Col1 Col2 Col3
sa ds fd

If this is my data

The stage variable will get evaluated this way

col1||col2||col3 = SVcur
SVcur = SVPrev
Svflag= if SVPrev<>SVcur then T else F

so finally it will result in F for all the records.
It goes this way

sadsfd= SVcur
sadsfd = SVPrev
Svflag= if sadsfd <> sadsfd then T else F

So it will be F always. Correct me If I was wrong.

Thanks.
sandeepgs
Participant
Posts: 87
Joined: Wed Jul 02, 2008 12:22 am

Post by sandeepgs »

mdbatra wrote:Make stage variable for every column & write its derivation as Trim(col_name) or whatever u need.

Now in output col derivation, compare the input_col with all the stage variables except the one defined for that particular column itself.
Hi Batra,

As you said If I create stage variable for 30 col and compare each col with all the stage variables (Derivations). As I undrestood it is same as writing a constraint comparing all the columns . So i think that it is same but we are writing a derivation insted of constraint.

So what I think is it is better to use constraint instead of stage variable because stage variables willl effect performance. But as I told you if I go for constraint it is increasing my querry size.

Correct me if I was wrong..
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Topic Relocated per request - Andy
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 »

Moderator please move to the, oh I don't know... General forum.
-craig

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