Composite Key Duplicate Check
Posted: Mon Dec 06, 2010 5:37 pm
Hi Everyone,
I have a small table with a 3 data element composite key. My requirement is to check for duplicates within this composite key. Here is the approach that I am taking.
Create a derived column D in a transformer that holds the values of these fields by using this logic.
The next stage is a Sort Stage and I am sorting the data on my new derived column and setting the 'Create Key Change Column' attribute = True. After the Sort Stage I am validating my duplicates in another transformer by using this logic:
2 questions regarding this example:
Is there a better way to handle a potentially NULL input column other than assigning a -1 (or some other arbitrary value) to the derived column and rejecting this record to a DataSet or Error Table?
Is this the best practice method of checking for duplicates in DataStage? I think that the new functionality in 8.5 may prove extremely useful in this case, but I just wanted to see if there are any other suggestions.
Thanks for reading this post!
Josh
I have a small table with a 3 data element composite key. My requirement is to check for duplicates within this composite key. Here is the approach that I am taking.
Create a derived column D in a transformer that holds the values of these fields by using this logic.
Code: Select all
If IsNotNull(Src.A) Then
If IsNotNull(Src.B) Then
If IsNotNull(Src.C) Then
Src.A : Src.B : Src.C
Else
-1
Else
-1
Else
-1
Code: Select all
If IsNotNull(DupeCheck.D) Then
If DupeCheck.keyChange = 0 Then
'InternalErrorCode'
Else
SetNull()
Else
SetNull()
Is there a better way to handle a potentially NULL input column other than assigning a -1 (or some other arbitrary value) to the derived column and rejecting this record to a DataSet or Error Table?
Is this the best practice method of checking for duplicates in DataStage? I think that the new functionality in 8.5 may prove extremely useful in this case, but I just wanted to see if there are any other suggestions.
Thanks for reading this post!
Josh