Help with logic in the Transformer

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
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Help with logic in the Transformer

Post by Hope »

I am writing a logic in the Transformer.This logic gives me the expected results. But my Performance goes down with this logic in the transformer.Please help me in writing a better logic than this.

if col1= '8000' OR col1 ='8100' OR col1 ='8300' OR col1='8301' OR col1='8302' OR col1='8400'
OR col1='8401' OR col1='8402' OR col1='8403' OR col1='8404' OR col1='8500'
OR col1='8520'
then '1100' else if col1='8099' then '1000'
else if col1='8820' then '1510'
else if (col1)='8020' OR (col1)='8203' then '1300' else
if (col1)='8600' OR (col1)='8601' OR (col1)='8602' OR (col1)='8603'
OR (col1)='8604' OR (col1)='8650' OR (col1)='8920' OR col1='93' OR col1='95' OR col1='87' then '1200' else '1100'

Thanks in advance
Hope
mahadev.v
Participant
Posts: 111
Joined: Tue May 06, 2008 5:29 am
Location: Bangalore

Post by mahadev.v »

What is the data type of 'col1'? If it is integer then remove the single quotes during comparisons. I guess number compares work faster than string compare.
"given enough eyeballs, all bugs are shallow" - Eric S. Raymond
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The Index() function may be faster. For example:

Code: Select all

If Index("8000,8100,8300,8301,8302,8400,8401,8402,8403,8404,8500,8520", InLink.col1, 1) Then "1100" Else ...
That having been done, arrange the comparison string in order of likelihood of occurrence to get optimum speed of match.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Or you could have the data in a file or table and use a lookup stage
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

Thanks for the suggestions
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

Hope wrote:Thanks for the suggestions
Any feedback on which solution worked for you?
Phil Hibbs | Capgemini
Technical Consultant
Hope
Participant
Posts: 97
Joined: Sun May 13, 2007 2:51 pm
Contact:

Post by Hope »

I kept the data in a file and used a lookup stage .
Post Reply