Loading parent/child tables in one job

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
jherr22
Premium Member
Premium Member
Posts: 56
Joined: Mon Jan 29, 2007 3:24 pm
Location: Denver
Contact:

Loading parent/child tables in one job

Post by jherr22 »

I have a job where I split off from a transformer to load two Oracle tables, one parent, and one child. Even though I ordered the links appropriatly in the transformer stage (parent load first, child second), the child table does not get loaded. I assume it is because the parent Oracle stage has not committed the transaction before the child table attempts to load. What I have done is create a data set down the child link, then in another job, load the data set into the child, but I would prefer to do it all in one job.

Interestingly, when I put a copy stage down the child link, then write to the DB and a file, it seems to "slow down" the processing of the child enough to allow the load to occur, but I do not think that is guaranteed.

Any suggestions?
shamshad
Premium Member
Premium Member
Posts: 147
Joined: Wed Aug 25, 2004 1:39 pm
Location: Detroit,MI

Post by shamshad »

If I were in your place, I would always run 2 separate jobs, one for parent and one for child and set dependency of the job that is supposed to run latter on successful completion of the former job.

This way we can mainting data consistency plus have more control on the end to end execution
Datawarehouse Consultant
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Yes you can do this but it is tricky.
First of all you need to ensure the parent population first and then child.

1. Use parent oracle stage write method as upsert
2. Parent oracle stage properties : Reject mode is true
3. Get reject link from that parent oracle stage and join with the input child link
4. Output of join (Join stage) to child oracle stage.

I hope this will help you to do what you want.
csri
Participant
Posts: 99
Joined: Wed Jul 11, 2007 8:02 am

Post by csri »

I appolize for my intrusion but my question is related to approach on this topic.

Girija, by setting "Reject mode" to true on parent stage will the reject link receive every row written to parent table? If not how does it work.

Are you suggesting the following job design:

Code: Select all

                 parentlink   
seqfile----->Xmer------->OraEnterpStgforParent
             |  |
   childlink |  |parentrejectlink
             |  |
             V  V
            JoinStg  
              |                     
              |                     
              |                     
              V                     
  OraEnterpStgforChild

Thanks for your suggestion.
John Smith
Charter Member
Charter Member
Posts: 193
Joined: Tue Sep 05, 2006 8:01 pm
Location: Australia

Post by John Smith »

How about turning off your FK constraint and loading both tables and then reenable FK post completion of your job?
jherr22
Premium Member
Premium Member
Posts: 56
Joined: Mon Jan 29, 2007 3:24 pm
Location: Denver
Contact:

Post by jherr22 »

girija: Thanks! Will this work even though nothing will go down the reject link? (I think this is what csri is getting at).

Smith: We thought of disabling the FK as you mentioned, but the powers that be will not allow this.
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Sorry for late reply !!!!!!!!!!!!!

parentlink
seqfile----->Xmer------->OraEnterpStgforParent
| |
childlink | / |parentrejectlinkrom Oracle stage
| /
| /
| /
V V
JoinStg (with sort restrict till parent finished)
|
|
|
V
OraEnterpStgforChild

Assuming that there should not be any data coming from parent reject link.

Thanks
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sheesh... don't people 'preview' what they are going to post? ASCII art requires the "diagram" be enclosed in code tags to retain all of that loverly whitespace so the picture makes some sense.
-craig

"You can never have too many knives" -- Logan Nine Fingers
girija
Participant
Posts: 89
Joined: Fri Mar 24, 2006 1:51 pm
Location: Hartford

Post by girija »

Sorry Craig !

I think it will make more sense now.

Code: Select all

                 parentlink    
seqfile----->Xmer------->OraEnterpStgforParent 
             |                        / 
   childlink |                     / reject link from oracle stage
             |                    /
             |                  /
             |                /
             |              /
             V            V 
            JoinStg  (Required to restrict the childlink until parent finished)
              |                      
              |                      
              |                      
              V                      
  OraEnterpStgforChild 
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There ya go! :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply