Hi,
I want to validate the data types of the source records.After validating I should pass all invalid data to the reject link and valid data to output link.I am using isvalid() function for this but don't know how to direct the reject records to output link.
validate datatype
Moderators: chulett, rschirm, roy
The 'direction' would be controlled by constraints. Perhaps leverage stage variables, one for each field to validate. Valid = 0, Invalid = 1 and lastly sum them. Good row constraint: sum = 0, reject everything else. Something like that, anywho.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
I take this exact approach in code I've written, except I want an audit field to tell me which fields were in error.chulett wrote:The 'direction' would be controlled by constraints. Perhaps leverage stage variables, one for each field to validate. Valid = 0, Invalid = 1 and lastly sum them. Good row constraint: sum = 0, reject everything else. Something like that, anywho.
Snippets of my code are:
Stage variables C1-C20 ("constraint" 1 - 20)
C1: If IsNull(Lookup_Account.AccountNK) Then "GL4Account;" Else \\
C2: If IsNull(Lookup_Bus_Unit.BusinessUnitNK) Then "GL4BusinessUnit;" Else \\
etc...
Audit: If Len(Trim(C1:C2:C3:C4:C5:C6:C7:C8:C9:C10:C11:C12:C13:C14:C15)," ","A") ne 0 Then " Failed Lookups: " : (C1:C2:C3:C4:C5:C6:C7:C8:C9:C10:C11:C12:C13:C14:C15) Else \\
InvalidRecord: Len(Audit) ne 0
Then my constraints are Not(InvalidRecord) for good records, and InvalidRecord for bad records.
If you use Craig's approach with boolean values for validation checks, replace Len(...) with either C1+C2+C3+... or Sum(C1:@FM:C2:@FM:C3:...) (See doc for SUM function)
HTH...
Scott
Some people are the Michael Jordan's of Datastage. I'm more like Muggsy Bogues