Page 1 of 1

Increment sequence

Posted: Tue Nov 25, 2008 12:45 am
by dsdevper
hi

I have to increment a integer field coloumn value by one if the there is a duplicate row.

Ex:INPUT(COLA,COLB,COLC ,COLD--KEY COLUMNS)

COLA COLB COLC COLD
-----------------------------------
111 EEE 8XX SSSS
222 AAA 9XX SGDH
222 AAA 9XX HUDG
222 AAA 9XX INKH
333 KKK 7XX HJHJ
333 KKK 7XX JHLJ
333 III 6XX JKKK

OUTPUT:(COLA,COLB,COLC,INT---KEY COLOUMNS)

COLA COLB COLC INT
-----------------------------------
111 EEE 8XX 1
222 AAA 9XX 1
222 AAA 9XX 2
222 AAA 9XX 3
333 KKK 7XX 1
333 KKK 7XX 2
333 III 6XX 1


please give me some sujestions.

Posted: Tue Nov 25, 2008 2:37 am
by us1aslam1us
Simple solution will be to use stage variables. Try something like this....
Sort the data on your three columns.
Initialize sVValue as 1

Code: Select all

sVCurrent = COLA:COLB:COLC
sVValue = If sVCurrent = sVPrevious then sVValue+1 else sVValue
sVPrevious = sVCurrent
And use sVValue in your column derivation of INT column.

Posted: Tue Nov 25, 2008 3:37 am
by srinivas.g
Design is

Sequential File-->sort -->transformer--->Dataset

In Sort stage ,

set create cluster key change column = true

and in transformer use stage variable
Dup = If clusterKeyChange=1 Then clusterKeyChange Else Dup+1

Dup value is your output.