Carrying value from B/Job routine to Job transform 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
yserrano
Premium Member
Premium Member
Posts: 52
Joined: Thu Jan 31, 2008 1:23 pm
Location: Santo Domingo

Carrying value from B/Job routine to Job transform stage

Post by yserrano »

Hello all, I need your help again :)
This time with a Before-Job Subroutine.
I customized some code found in this forum to access an Oracle table from my routine, this is an excerpt of the code:

Code: Select all

Stmt= "select max(":field:") from ":table: " ;"
Call DSLogInfo("Query SQL: " : Stmt, "ExecSQLProc") 
ErrCode1 = SQLBindCol(hStmt, 1, SQL.B.DEFAULT, res1)
status = SQLExecDirect(hStmt, Stmt) 
This is working nice, and what I need now is to carry on the value assigned to res1 to a job tranformer stage. Is it possible? How? Are there different methods to acomplish this?

I intensely searched the forum for some solution before I posted this but only found workarounds for similar situations involving job sequences, which is not my case.
I tried with environment variables without success.


P.D. Want to thank you for the sample code regarding SQLExecDirect and ODBC usage, good job!
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

How about not using the before-job routine and using the initialize stage variable functionality? When the Transformer starts, the stage variables initialize themselves. This can include running a process such as a Function, which can in turn do exactly the same steps as the before routines. The best part is that they are Functions, which means that cool Test button works! 8)
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 »

In other words, you can't do what you want from 'before job'.
-craig

"You can never have too many knives" -- Logan Nine Fingers
yserrano
Premium Member
Premium Member
Posts: 52
Joined: Thu Jan 31, 2008 1:23 pm
Location: Santo Domingo

Post by yserrano »

kcbland wrote:When the Transformer starts, the stage variables initialize themselves. This can include running a process such as a Function...
With this approach the function will be called once for every row processed by the job, right? Impacting job performance directly.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No - Ken is suggesting the work be done in the Initial Value section of the stage variable's definition, which means it will only happen once per run.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Try it - you'll like it. Initialize stage variables is amazingly powerful functionality.
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 »

Exactly, it's very cool when it all clicks for you. You then leave the derivation blank in the Transformer so that the value stays static over the course of the run. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
yserrano
Premium Member
Premium Member
Posts: 52
Joined: Thu Jan 31, 2008 1:23 pm
Location: Santo Domingo

Post by yserrano »

Done. Thank you!
Excelent help as usual.
Post Reply