Page 1 of 1
constraint not restricting before condition
Posted: Sat Nov 05, 2011 12:19 pm
by times29
i have source-->lkup-->transf--> 2 target tables table_a and table_b
in transf i am giving condition if condition met for table_a load table_a else if condition
meet for table_b load table_b (Condition is a constraint)
In both target tables i have before condition to truncate table
so if condition for table_a is met it do load table_a and truncate it
but even its not inserting any rows in table_b its still performing before condition
any idea why?
Posted: Sat Nov 05, 2011 2:24 pm
by chulett
Yes. Anything "before" the stage happens when the stage is opened / initialized / when the database connection is made. It doesn't wait for the first row to arrive before it fires, if that's what you are thinking would happen.
Posted: Sat Nov 05, 2011 6:29 pm
by times29
What i am asking is if constraint is not met how can i prevent it from
initializing the database table .
Posted: Sat Nov 05, 2011 8:41 pm
by chulett
You'll have to remove the truncation from the target stage itself as there isn't a mechanism there to make it conditional, as far as I know. Perhaps others have dealt with this and can offer more cogent advice, I'm thinking of some kind of a routine call that is only made when the first row passes through. Running on multiple nodes would complicate that appoach, however.
Another approach would be a quick check before the job runs, another job that does a join or gets a count of the results to know if one or both targets will have rows heading their way and simply truncates one or both targets. Then your load job can run and not have to worry about it.
Posted: Mon Nov 07, 2011 2:13 pm
by jwiles
One solution would be to write the A and B data to datasets or sequential files and move the loads into separate jobs. Within a sequence, use a routine to see if there is data present for each table. Only when data is present (ready for loading) do you actually execute the load job for the table. If there's no data for a table, you don't execute it's load job and the table isn't truncated.
Regards,