Passing formula as a parameter

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
bobby28
Participant
Posts: 17
Joined: Mon Jan 17, 2005 9:56 am

Passing formula as a parameter

Post by bobby28 »

Hello:
I am trying to implement some business rules within my ETL and the requirement is to pass a formula into the ETL upon runtime. The formula may change over time, for example we maintain a formula some where external to the ETL that defines the price - Price = x + 2.5 y and may change to Price = x +0.78y in future. Assuming that number of parameters remain the same, can we pass this formula into ETL at runtime?

What are some of the ways to handle this?

Thanks for your help.
Bobby
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

You can't pass in expressions in the normal sense. The source code is a compiled program, so a parameter of logic can't possible be compiled

There is a possibility of using an obscure method in the OCONV function of achieving what you need. It's fairly complicated and has a whole lot of conditions behind how you can use it, I don't recommend you taking this path.

Something to consider is putting the data into a table and using a SQL script to evaluate the data content. There's really no graceful way of doing this within Server.
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Assuming the formula is static and just that value can change, make it a job parameter. Or a single record hashed file pulled in at runtime in the Initial Value of a stage variable using something akin to 'UtilityHashLookup'. Or it can be echo'd in from a flat file. Or simply use a cached reference lookup.

As Ken notes, there really isn't any graceful way to do a truly dynamic expression / formula.
-craig

"You can never have too many knives" -- Logan Nine Fingers
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

If you standardize your link names and use them in your formula you can pass them to your ETL jobs as parameters:

For Ex:

LinkName.x + 2.5 * LinkName.y

or

LinkName.x + 0.78 * LinkName.y

In the above case where number of parameters remain the same and just a value for transformation keep changing, you might just want to pass that value as parameter:

LinkName.x + TransformValue * LinkName.y
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

JoshGeorge wrote:If you standardize your link names and use them in your formula you can pass them to your ETL jobs as parameters:

For Ex:

LinkName.x + 2.5 * LinkName.y

or

LinkName.x + 0.78 * LinkName.y

In the above case where number of parameters remain the same and just a value for transformation keep changing, you might just want to pass that value as parameter:

LinkName.x + TransformValue * LinkName.y
I don't think this works.
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't think so either. Passing them in from outside means they are just strings inside the job, it won't recognize them as valid link and column names.

Be glad to be proven wrong, however. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

That appears to be ambitious attempt. Yep LinkNames theory won't work,
but the last part :
JoshGeorge wrote: In the above case where number of parameters remain the same and just a value for transformation keep changing, you might just want to pass that value as parameter:

LinkName.x + TransformValue * LinkName.y
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Of course, and something I'd already posted earlier. :wink:
-craig

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