Query about writing expression

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
udayk_2007
Participant
Posts: 72
Joined: Wed Dec 12, 2007 2:29 am

Query about writing expression

Post by udayk_2007 »

Hello guys

I have a question about writing a expression.If i am using a string function (ex.concatenation),will it be efficient to write derivation directly in column derivation or calculating it first in stage variable and then assigning it to column derivation will work faster

Thanks for your help

Regards
Ulhas
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

Unless you are going to reuse the derivation more than once its better off to do it straight in the column derv rather than a stage variable.
udayk_2007
Participant
Posts: 72
Joined: Wed Dec 12, 2007 2:29 am

Post by udayk_2007 »

yes..looks logical

Thanks

Regards
Ulhas
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

A derivation is a derivation, it won't matter where it is when it comes to how long it takes to be evaluted. As noted, one typically uses a stage variable to do something once and allow it to be reused in multiple places, be it other stage variables or in a column's derivation. That can even be something as simple as resolving a function like CHAR(10) once rather than over and over again for every record.

However, that being said, there are other reasons for using stage variables rather than just re-use. They also allow larger, more complex derivations to be broken down into logic chunks and 'self documented' via the use of intelligent stage variable names. Or even if not all that complex, it can make a job much more readable when you leverage a well-named stage variable in a constraint or derivation rather than the actual 'code' itself. As another example, you might need to check 4 or 5 things to determine if a row is "valid" or not and doing that in a boolean stage variable allows the outgoing constraint to be something like "svIsValid" rather than an awkard if-then-else mess.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply