Defining Constraints in Transformer Stage

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

Post Reply
yaminids
Premium Member
Premium Member
Posts: 387
Joined: Mon Oct 18, 2004 1:04 pm

Defining Constraints in Transformer Stage

Post by yaminids »

Hello there,

I am trying to distribute data in the source table into three target tables based on the values in the source columns. I am trying to accomplish this by defining a constraint in the 'Transformer' Stage. When the source column is of numeric type, I have no problem in defining the constraint but when the source column is of Character type I am not able to define the Constraint. Can anyone explain to me how to define a Constraint on a 'Character' column.

Thanx in advance.
-Yamini
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's nothing different about the way a constraint is defined for character versus numeric data. You code an expression that evaluates to True or False and the row either is passed out through the constrained link or not, respectively.

You may be having an issue with the nature of the data you are trying to contrain on. Why don't you post some examples, samples of 'good' data versus 'bad' data (data that should evaluate as TRUE or FALSE) and what you've tried in the way of a constraint expression so far.
-craig

"You can never have too many knives" -- Logan Nine Fingers
datastagedummy
Participant
Posts: 56
Joined: Thu Feb 13, 2003 6:08 pm
Location: USA

Re: Defining Constraints in Transformer Stage

Post by datastagedummy »

Can you post the text from your constraint link and hopefully you dont have the rejects checked for any of the links above.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Make sure you use quotes around literal values being compared to character columns. If you use literal values that are numeric and compare them to character or numeric columns, then you're okay.

x is integer
x=10 is okay
x=A is bad
x='A' is okay

x is char
x=10 is okay
x=A is bad
x='A' is okay
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
yaminids
Premium Member
Premium Member
Posts: 387
Joined: Mon Oct 18, 2004 1:04 pm

Post by yaminids »

Hi,

These are the conditions I was using to define the Constraints.

DSLink3.Name = 'SUN' (It does'nt work)
DSLink3.Age = 26 (It works fine)

Can you explain me what is the problem.

Thanx in advance.
-Yamini
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Your link.column value either has an case mismatch or leading/trailing spaces, from what I can guess. I suggest you find out the exact contents, and either apply a TRIM and/or UPCASE function where appropriate.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ketfos
Participant
Posts: 562
Joined: Mon May 03, 2004 8:58 pm
Location: san francisco
Contact:

Post by ketfos »

Hi,
You can use Num function to check
what DSLink3.Name returns?

This will determine if the string is NUMERIC

Ketfos
ririr
Participant
Posts: 84
Joined: Sun Apr 04, 2004 8:59 pm

Post by ririr »

Try wrapping the TrimB(TrimF(LINK.COLUMNNAME))="SUN"..
yaminids
Premium Member
Premium Member
Posts: 387
Joined: Mon Oct 18, 2004 1:04 pm

Defining Constraints

Post by yaminids »

Hello there,

Thank you all for your suggestions. I got the solution for the problem. Actually, there were some leading spaces in the 'Name' column.

-Yamini
T42
Participant
Posts: 499
Joined: Thu Nov 11, 2004 6:45 pm

Post by T42 »

This is yet another perfect example of why it is important to remember:

No matter what we use, it must be PRECISE. If you want a flexible rule-based comparison, check out QualityStage. DataStage is superior when it is dealing with precise data comparison. Leading/trailing spaces, extra whitespaces, invisible characters, and so on forth, can screw up DataStage's results unless you compenstate for it.

This reminds me of a recent client's issue with transferring data from a mainframe computer that includes NULL as a valid character. It had to be converted ahead of time before it can be read in. Data integrity is as important to deal with these days.
ranga1970
Participant
Posts: 141
Joined: Thu Nov 04, 2004 3:29 pm
Location: Hyderabad

Re: Defining Constraints in Transformer Stage

Post by ranga1970 »

Did you try UpCase(trim(UR Input)="SUN"
Becase Datastage case sensitive and space validater

Ranga
RRCHINTALA
dsxdev
Participant
Posts: 92
Joined: Mon Sep 20, 2004 8:37 am

Post by dsxdev »

Hi,

If you are really dealing with a char type column then you cannot trim a char type column,even if you trim a char type column value remains same, padding will still be there. For such column convert it to varchar and then use

Code: Select all

TrimLeadingTrailing(inputcolumn)="Value"
Happy DataStaging
rasi
Participant
Posts: 464
Joined: Fri Oct 25, 2002 1:33 am
Location: Australia, Sydney

Post by rasi »

Make it a practice to always trim the strings before doing any validataion.

Cheers
Regards
Siva

Listening to the Learned

"The most precious wealth is the wealth acquired by the ear Indeed, of all wealth that wealth is the crown." - Thirukural By Thiruvalluvar
yaminids
Premium Member
Premium Member
Posts: 387
Joined: Mon Oct 18, 2004 1:04 pm

Defining Constraints in Transformer Stage

Post by yaminids »

Hello all,

Thank you very much for your suggestions.
-Yamini
Post Reply