Delete then insert records

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
babbu9
Premium Member
Premium Member
Posts: 75
Joined: Tue Jun 01, 2004 9:44 am

Delete then insert records

Post by babbu9 »

Hi
I am working with the Oracle Enterprise stage and would like to truncate a table and then insert records into it.
I tried the load option in the stage but it gives an error. I would like to do this by including custom code in the oracle stage, first truncate then insert records.How do I do this?


Please inform.

Bob
kwwilliams
Participant
Posts: 437
Joined: Fri Oct 21, 2005 10:00 pm

Re: Delete then insert records

Post by kwwilliams »

babbu9 wrote:Hi

I tried the load option in the stage but it gives an error. I would like to do this by including custom code in the oracle stage, first truncate then insert records.How do I do this?
Bob,

What errors does it throw? If it could run without custom code would you prefer that? Did you have disable contraints = True and have the indexes set to rebuild? Other issue could be permissions, to truncate the table you either have to log in as the schema owner or have alter privileges on the table and all of its indexes.

Keith
klarson88
Participant
Posts: 9
Joined: Wed Jan 28, 2004 11:37 am
Contact:

Re: Delete then insert records

Post by klarson88 »

babbu9 wrote:Hi
I am working with the Oracle Enterprise stage and would like to truncate a table and then insert records into it.
I tried the load option in the stage but it gives an error. I would like to do this by including custom code in the oracle stage, first truncate then insert records.How do I do this?


Please inform.

Bob
We created a PL/SQL for similar item, except that we wanted to delete records from the table by source (one out of four) by day. We created a routine to execute before running the load job, but you could also call the procedure in the SQL/BEFORE window within the job.
babbu9
Premium Member
Premium Member
Posts: 75
Joined: Tue Jun 01, 2004 9:44 am

Post by babbu9 »

Thank you for the mail. SQL before window exists in server jobs and not in parallel. I have not looked into the drop constraints and rebuild indexes options in parallel.

Thanks again.
raj_konig
Participant
Posts: 67
Joined: Thu Dec 22, 2005 12:27 am

Post by raj_konig »

Hello Babbu,

Just create another instance of the same table for the delete action. Make sure that the inputs for insertion and deletion instances of the table comes from the same transformer. Also make sure that delete output from the transformer should be done first before the insert.

Thanks,
rajesh
Post Reply