Duplicate Records

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Duplicate Records

Post by praburaj »

Hai,

I have one problem. I need to check duplicate record from two column.

If it is duplicate record, that record store in to Error Table.


Ex:

Name Age

Raj 25

kamal 45

vinodh 40

Raj 25


Now , the dublicate record is Raj. This Raj record is send to the Error

Table.

How can i do that. Can any one help me?.


Regards,

prabu
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

You can do it using
the sorted data and checking for duplicates using the stage variables within the transformer.
Success consists of getting up just one more time than you fall.
ramudwhelp
Participant
Posts: 24
Joined: Mon Jul 24, 2006 12:30 am

Post by ramudwhelp »

Use Aggregator Stage and make group by on both columns.
Ramakrishna
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Perform a search on this forum, this has been discussed many times.
Search for "How do I remove duplicate rows from a data source?" in FAQ.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

My condition is that dupicate records store in to the Error Table (

Target_Sequential file) help me the query. If i use Aggregator Stage, is

it show the duplicate records separately. Otherwise, if any condition for

this, can u . I need two check these two colums AcctCode and DeptCode

give me the query.


Regards,

prabu
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

No need to go for aggregator stage.

Sort the data first (based on the two columns).

Then check the duplicates through the stage variables if found pass it to the error table link else to the target link.
Success consists of getting up just one more time than you fall.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Once i sort the data, that duplicate records will be removed. I don't

want. I need send Duplicate Record in to target link( Error_Target). Can

u give me the query :cry:
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

How are you sorting the data?

You can use the sort stage for the puppose, it won't remove the duplicates.
Success consists of getting up just one more time than you fall.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Ok, Now, I am using the Sort Stage I sort the data. Then How can i write

query in Transformer. I know that , create Stage Variable. My

Comparing column in Acct Code, DeptCode. Can u help me the query.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Ok, Now, I am using the Sort Stage I sort the data. Then How can i write

query in Transformer. I know that , create Stage Variable. My

Comparing column in Acct Code, DeptCode. Can u help me the query.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

You don't write a query in transformer. Its the place where you do the transformation.

Take two stage variables
Prev_Row
Curr_Row

Set Curr_Row to Col1 : Col2
Constraint for the Target Link
Curr_Row<>Prev_Row
Constraint for the Error Link
Curr_Row=Prev_Row

Then set
Prev_Row=Curr_Row

It should give you the outline of how you should proceed.
Success consists of getting up just one more time than you fall.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

i tried ur ida. But it is not work. I tried Like that.

PrevRow -----------------> AccCode

CurrRow ------------------> DeptCode


Then Set in constraints

Error Records:

CurrRow=PrevRow

Good Records:

CurrRec<>PrevRec


In Error Records Link did not show any records. It is showing only Zero

Records. Can u help me other one.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

Please read my earlier post again, I asked you to use derivation of Curr_Row to concate of the AccCode and DeptCode. i.e.
Set Curr_Row to AccCode : DeptCode
Success consists of getting up just one more time than you fall.
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Post by praburaj »

Hai lovejo,

I also tried what u said. But still it is not work.


what i did there. (Acc Code and Dept Code)

Stage Variable:

Prev Row--------------------> Acc Code

Curr Row---------------------> Acc Code : Dept Code

In Constraints:

Good Records:

CurrRow<> PrevRow

Error Records:

CurrRow = PrevRow


I tried what u said. But still it show zero record in Error Table. I dont

know that why it is show. If i did any mistake, can u help me where i did

make mistake and How can i correct it. plz Help me.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

praburaj wrote:Hai lovejo,

I also tried what u said. But still it is not work.


what i did there. (Acc Code and Dept Code)

Stage Variable:

Prev Row--------------------> Acc Code

Curr Row---------------------> Acc Code : Dept Code

In Constraints:

Good Records:

CurrRow<> PrevRow

Error Records:

CurrRow = PrevRow


I tried what u said. But still it show zero record in Error Table. I dont

know that why it is show. If i did any mistake, can u help me where i did

make mistake and How can i correct it. plz Help me.
Prabhu,


As lovejha mentioned have two stage variables.

1.IsReject ---> if link.AccCode:link.DeptCode = PrevRow Then 1 Else 0
2.PrevRow----> link.AccCode:link.DeptCode

In the error link constraints:
IsReject = 1

In the other link:
IsReject = 0
Post Reply