Best way to delete rows via OCI8?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
bradinmi
Participant
Posts: 17
Joined: Wed Apr 02, 2003 9:06 pm
Location: Detroit

Best way to delete rows via OCI8?

Post by bradinmi »

We have a monthly job to delete rows from an Oracle table. There are two ways to go about this, and I'm wondering which is the most efficient and easiest to recover from if there's a problem.

Option one is to have an OCI8 stage that issues a seperate DELETE command for each row we wish to delete, issueing a COMMIT (Transaction Handling) after every so-many rows, like 50,000. This method would first entail using a SELECT command to get the ID's we need to remove and putting them in a sequential file as input to the stage to do the DELETE.

The second option is to issue one DELETE command with an incoming parm value of a date. For example,
DELETE FROM MY_TABLE WHERE POSTING_DATE < '01-MAR-2003'

Which would work the best?


Brad Vincent
Compuware @ The Detroit Medical Center
steven
Participant
Posts: 14
Joined: Thu Apr 24, 2003 12:00 pm
Location: Montreal, Canada
Contact:

Post by steven »

In our current project, we need to do DELETE as well and we use the PRE-SQL option in our Target OCI. Write your load job as you will and in your target OCI, there's a tab for Pre and Post SQL. Put your DELETE statement right there and the records are deleted before the first insert happens.

Don't know if this is suitable for you...but works well for us. We preferred this option to the first one you mention

Steve
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

That's a good point, for a single large transaction Oracle needs rollback space, and if there is a trigger on the table the transaction can become very large. Single delete statements with 1000 row transactions should be more robust than a single delete for large amounts of data.

Vincent McBurney
Data Integration Services
www.intramatix.com
Post Reply