Populating user activity variable in a sequencer

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Populating user activity variable in a sequencer

Post by abc123 »

I have a job in a sequencer where I need to read the number of rows
in a table and based on that populate an user activity variable in the
sequencer. I am using the job to read the number of rows and put it in a
sequential file. I am then using an Execute Command stage to read the
value from the sequential file and populate the user activity variable.
Is there a more efficient way?
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You can read the "number of rows in a table" and directly write it to the DSSetUserStatus in the job.
(You need to write a simple routine)
Check this post

You can use this UserStatus later in your Job Sequence.

This way you can skip the Execute Command stage.
Lets wait on more efficient way, implemented by others
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
splayer
Charter Member
Charter Member
Posts: 502
Joined: Mon Apr 12, 2004 5:01 pm

Post by splayer »

I am using PX jobs so using DSSetUserStatus is not an option. What if I
write a custom server routine? I am thinking of something like this:

FUNCTION UpdateRowCount(Arg1)
Call DSSetUserStatus(Arg1)
Ans = Arg1
RETURN(Ans)

Now, which job's user status would this set? In my sequencer, I have,

JobActivity1 ----> JobActivity2

JobActivity1 calls a job which gets the number of rows using an Oracle
stage and puts it in a sequential file. JobActivity2 needs this value. I am
thinking may be JobActivity1 should be a server job. But how do I get the value so that JobActivity2 can use it?
I_Server_Whale
Premium Member
Premium Member
Posts: 1255
Joined: Wed Feb 02, 2005 11:54 am
Location: United States of America

Post by I_Server_Whale »

splayer wrote:I am using PX jobs so using DSSetUserStatus is not an option.
Are you and the OP (abc123) the same?
Anything that won't sell, I don't want to invent. Its sale is proof of utility, and utility is success.
Author: Thomas A. Edison 1847-1931, American Inventor, Entrepreneur, Founder of GE
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

In JobActivity 2, when double click the expression window open, right click on it you will find 'Activity Variables'. Choose that, you will see 3 options. One of them will be $UserStatus. Use that.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

I wrote a small routine called GetRowCount. How do I get the output of JobActivity1 so that I can set the UserStatus for this job activity? I would assume that there would some posts similar to this.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Post your routine. You can call DSSetUserStatus() function within that job to set the user status. And then retrieve it in a sequence job as i explained in my previous post.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not in a Parallel job. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

This is the routine:

FUNCTION UpdateUserStatus(intRowCnt)
Call DSSetUserStatus(intRowCnt)
Ans = intRowCnt
RETURN(Ans)

I can create a server job if needed as I am just doing a SELECT COUNT. However, I don't understand where in the job I need to call it. I guess I need a tranformer.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yes. Inside the transformer. Call your routine inside the transformer.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The method you're using (via a file) is adequately efficient.

Even a job's user status area involves writing to and from disk, so there's no big gain there. The main additional cost is the additional file opens and closes (a total of four operations, and thus negligible).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

Ok. So here is the interesting part. My server job has:

Oracle stage----> Transformer ----> SeqFile

However, the SeqFile stage is completely unnecessary but I am forced to use it as I don't have the output side without it. In the derivation of the output column, I execute the routine which sets the userstatus of the job. Is there a way around it without adding an extra seq file stage?
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

You need to add a Sequential File Stage or something else as an Output.
But you have the option to write the output to /dev/null with the Sequential File Stage

In the file name space use this /dev/null
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Incidentally, none of this is possible in a sequencer.

It is, however, possible in a job sequence.

A sequencer is a component in a job sequence that makes an "any or all" decision based on whether its inputs have fired.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Alternatively BASIC Transformer can also be used in PX job for the same reason. Or the rowcount can be written into a Sequential file, and Execute command activity can be used to read and pass it as a variable.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply