How to wait until all the data on a link is processed?

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
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

How to wait until all the data on a link is processed?

Post by yabhinav »

Hi,

I have a job which reads data from a file. The file has data in the following format

Header
Detail
Detail
Detail
Detail
Trailer

The job design is simple. I have a sequential file stage followed by a transformer which separates the header, detail and trailer.

The header link will go and insert into a table and likewise for the detail
Once the trailer message comes it will kick off a function that will update the data inserted by the detail flow.

The problem is that, before the last detail message is inserted, the trailer is fetched and the function is not updating the last detail message.

I want to know if there is any way for the job to wait until the detail messages are processed and then fetch the trailer?
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

What target stage are you using?

You could try putting a reject link from the detail insert stage and placing that as a referential lookup into the msg trailer link. This should, in theory, make the flow from the msg trailer link wait until all the inserts into the table have finished, then continue on from the lookup to use the msg trailer link to do what ever it has to do.

Once again only a theory, not sure if it will actually work.

Or you could just do it in two different jobs.
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

Post by yabhinav »

Thanks for the suggestion Shane, but we are using a custom stage called UOW.

So i will not be able to have reject links on it.

I can't use two different jobs because I need to pass some values coming in from the trailer to the function.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Not fully sure what you need.

Did you try running that stage(s) / job in a sequential mode or in 1 node config ?
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

Post by yabhinav »

Sainath.Srinivasan wrote:Not fully sure what you need.

Did you try running that stage(s) / job in a sequential mode or in 1 node config ? ...
Yes Sainath, the job is running on a single node.

And my problem is even before my detail record is insert into the database my trailer record is calling a function which will updated a column on the inserted details. Effectively missing out on updating the last detail column. I just want my trailer to wait till all the detail message are laoded
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

That may be because of pipeline parallelism.

Include a dummy lookup stage just before writing the target trailer to lookup some dummy value from the detail stream. This may cause the necessary delay.

Btw, does the trailer calculation function happen in the database ?
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

Post by yabhinav »

Thanks Sainath, forcefully creating a delay should work, for that I just added a Sleep 10 secs in the function.

I was just wondering if there was any way to handle it in Datastage.

I'm calling the function in a Lookup so ya the calculation will happen on the database
battaliou
Participant
Posts: 155
Joined: Mon Feb 24, 2003 7:28 am
Location: London
Contact:

Post by battaliou »

Use 2 jobs. Alternatively create an "After job function". If you dont want to use 2 jobs, you'll have to sort/aggregate your data on the trailer link - not necessary.
3NF: Every non-key attribute must provide a fact about the key, the whole key, and nothing but the key. So help me Codd.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

yabhinav wrote: ... we are using a custom stage called UOW.

So i will not be able to have reject links on it.

I can't use two different jobs because I need to pass some values coming in from the trailer to the function.
I take it this means that your custom stage takes all the input streams for each file segment (header, detail, trailer) then updates using the function within the stage?

If that is the case, we can't really comment without knowing what the stage actually does.
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

Post by yabhinav »

I understand Shane. Anyways thanks for your help.
We came up with a work around for the problem.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Care to share?
:roll:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
yabhinav
Participant
Posts: 37
Joined: Wed Mar 05, 2008 11:54 pm
Location: Hyderabad

Post by yabhinav »

ray.wurlod wrote:Care to share?
:roll: ...
Sorry, I was away for a while.

We read Mq messages from a custom stage, so we added extra parameters to the stage to call a C function.
This C function will check if the incoming record is a trailer or not.
If it is, it will hold the trailer till all the messages in the queue are flushed i.e all the messages are processed and EOW has been received for each of them. After this the trailer will be processed
Post Reply