Use Stage Variables when datasource is empty

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
centennium
Premium Member
Premium Member
Posts: 15
Joined: Thu Mar 16, 2006 4:11 am
Contact:

Use Stage Variables when datasource is empty

Post by centennium »

Hi all,

I am using a Routine SetUserStatus in Stage variables in my jobs to capture info that is needed in next stages. But if the datasource is emtpy, there are no records flowing through the transformer and the Stage variable will not get a value.

SetUserStatus Routine:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

ErrorCode = 0

Call DSSetUserStatus(Status)

Call DSLogInfo("User Status Set To:  ":Status, "SetUserStatus") 


Ans = Status
In my Stage Variable I use:
SetUserStatus(If Read_Status.record_count_valid = RowCount Then 'OK' Else 'NotOK')

RowCount is a variable from the previous stage.

What I want to accomplish is that if RowCount = 0 and record_count_valid is null because the data source is empty, that the UserStatus also returns 'OK' but I don't seem to be able to accomplish this.

Any thoughts?

TIA

Martina
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What is your datasource? Is it a flat file or a database?
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 »

I would suggest that you use your routine in the Initial Value column where the stage variable is defined to explicitly set the value to 'OK' when the job starts. Leave your other mechanism in place so that it is still used when rows actually do flow through the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Status is a reserved word (it's both the name of a statement and the name of a function).

:idea: It's not good practice to use reserved words as variable or parameter names, in case they change the compiler to enforce the reservedness of these words. It's happened in other languages.
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 »

Yes, this routine wont be executed at all. You need to handle this in the receiving end. i.e., if you dont get any value set in the variable, you can replace it with 0.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

kumar_s wrote:Yes, this routine wont be executed at all.
:? It will if also called in the Initial Value area, as I noted.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Oh ok, so the intialization of variable occurs during intial validation phase and not during when stage start to operate. Thanks for that.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply