validate datatype

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vennam445
Participant
Posts: 20
Joined: Tue Oct 21, 2008 12:34 pm

validate datatype

Post by vennam445 »

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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
sbass1
Premium Member
Premium Member
Posts: 211
Joined: Wed Jan 28, 2009 9:00 pm
Location: Sydney, Australia

Post by sbass1 »

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. :wink:
I take this exact approach in code I've written, except I want an audit field to tell me which fields were in error.

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 :-)
Post Reply