Page 1 of 1

Conditional execution

Posted: Wed May 07, 2008 8:42 am
by kishorenvkb
Hello,

In a sequence I have an execute command which calls a bteq to populate a table. Upon successful... the sequence continues to executes the next stage, which is a datastage job that joins the table that is populated in the previous stage with another huge fact table.

Most of the time the first table that is populated will not have any rows. If there are no rows in this table, there is no need to execute the next stage (calls a ds job) to join the huge fact table to this empty table.

How can I avoid doing this? Basically, I want to continue to the next stage in the sequence, if there exists data in the table that I just populated.

Thanks

Posted: Wed May 07, 2008 10:06 am
by Minhajuddin
>You would have to get the count of records from your table somehow (Maybe create another job which gets the count)
>Read the count from the file which you created (You can do this using a small basic routine or by using an execute command activity)
>Branch using a conditional activity based on the output from the previous stage

Re: Conditional execution

Posted: Wed May 07, 2008 11:18 am
by priyadarshikunal
kishorenvkb wrote:Hello,

In a sequence I have an execute command which calls a bteq to populate a table. Upon successful... the sequence continues to executes the next stage, which is a datastage job that joins the table that is populated in the previous stage with another huge fact table.

Most of the time the first table that is populated will not have any rows. If there are no rows in this table, there is no need to execute the next stage (calls a ds job) to join the huge fact table to this empty table.

How can I avoid doing this? Basically, I want to continue to the next stage in the sequence, if there exists data in the table that I just populated.

Thanks

You have to many options
here are the two options

1. Get row count from the links
2. Count the number of rows in the table

and and don't forget to store it some where probably environment variable or user variable.
and on the basis of that you can trigger the job.
For more details on these options, search forum.

one more option is to wait for kim to see this message :wink:

Regards,

Posted: Fri May 09, 2008 1:25 pm
by kishorenvkb
You are right on the money. Yes, I need to have the count of rows in a table available in a sequence.
I have written the count to a text file.
The challenge is how to read the text file and get the count available in the sequence for me to perform a conditional branching of jobs.

Please assist.

Posted: Fri May 09, 2008 1:55 pm
by chulett
If you've got a simple count in a text file, you can easily build a routine to 'cat' the file and then capture the result. You can then branch based on that result.

Posted: Fri May 09, 2008 3:36 pm
by kishorenvkb
Thanks a bunch. It worked.

Posted: Fri May 09, 2008 5:12 pm
by ray.wurlod
Please mark the thread as Resolved.

Posted: Thu Jul 03, 2008 6:43 am
by manuel.gomez
chulett wrote:If you've got a simple count in a text file, you can easily build a routine to 'cat' the file and then capture the result. You can then branch based on that result.
how can we do this in Windows? I do have exactly the same problem

Posted: Thu Jul 03, 2008 7:06 am
by chulett
The same way. The MKS Toolkit will have a 'cat' command, I assume, or you can use the DOS command 'type' which will accomplish the same thing.

Posted: Thu Jul 03, 2008 7:09 am
by manuel.gomez
chulett wrote:The same way. The MKS Toolkit will have a 'cat' command, I assume, or you can use the DOS command 'type' which will accomplish the same thing.
True, sorry for asking!

Posted: Thu Jul 03, 2008 7:10 am
by manuel.gomez
chulett wrote:The same way. The MKS Toolkit will have a 'cat' command, I assume, or you can use the DOS command 'type' which will accomplish the same thing.
True, sorry for asking!