473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

EXPORT and Delete

Friends:

Let's say I'd like perform a delete, but before I delete, I'd like to
export the target rows.

I could use an export whose SELECT clause references the OLD TABLE of
a DELETE, but the issue is I'm deleting the table in chunks, like so:

WHILE (V_NO_DATA = 0) DO
DELETE FROM
(
SELECT 1 FROM X FETCH FIRST 200000 ROWS ONLY
) AS X_D';--
COMMIT;--
END WHILE;--

Since EXPORT won't append to the target export file, I'd end up
creating as many exports (and attendant files) as iterations in my
WHILE loop, which is no good.

As I understand it, EXPORT is not under transactional control, so I'm
wondering how I can ensure that I don't delete more rows than I export
(I don't mind deleting fewer, and I suppose intermediate updates are
an issue, either).

To avoid phantom/DR/Non-RR anomalies, would it be enough to specify
the isolation level of the EXPORT's SELECT and the SELECT in the
DELETE as WITH RR?

Anybody tackled this issue before?

(UDB LUW 8.2.3 on AIX 5.x)

--Jeff

May 7 '07 #1
6 4095
On May 7, 3:05 pm, jefftyzzer <jefftyz...@sbcglobal.netwrote:
Friends:

Let's say I'd like perform a delete, but before I delete, I'd like to
export the target rows.

I could use an export whose SELECT clause references the OLD TABLE of
a DELETE, but the issue is I'm deleting the table in chunks, like so:

WHILE (V_NO_DATA = 0) DO
DELETE FROM
(
SELECT 1 FROM X FETCH FIRST 200000 ROWS ONLY
) AS X_D';--
COMMIT;--
END WHILE;--

Since EXPORT won't append to the target export file, I'd end up
creating as many exports (and attendant files) as iterations in my
WHILE loop, which is no good.

As I understand it, EXPORT is not under transactional control, so I'm
wondering how I can ensure that I don't delete more rows than I export
(I don't mind deleting fewer, and I suppose intermediate updates are
an issue, either).

To avoid phantom/DR/Non-RR anomalies, would it be enough to specify
the isolation level of the EXPORT's SELECT and the SELECT in the
DELETE as WITH RR?

Anybody tackled this issue before?

(UDB LUW 8.2.3 on AIX 5.x)

--Jeff
Serge's "SQL on Fire" Part II has a promising lead--using a CTE I can
INSERT my DELETEd rows into a temp table and then EXPORT its contents.
That'll solve my isolation issues, but at the expense of INSERTing
into a table (I'd likely use a DGTT though, so the insertion cost
should be minimal).

Any other ideas, though?

--Jeff

May 7 '07 #2
jefftyzzer wrote:
Serge's "SQL on Fire" Part II has a promising lead--using a CTE I can
INSERT my DELETEd rows into a temp table and then EXPORT its contents.
That'll solve my isolation issues, but at the expense of INSERTing
into a table (I'd likely use a DGTT though, so the insertion cost
should be minimal).
I have never tried this, but export this query:
SELECT * FROM OLD TABLE(DELETE FROM T ...)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 8 '07 #3
On May 7, 5:45 pm, Serge Rielau <srie...@ca.ibm.comwrote:
jefftyzzer wrote:
Serge's "SQL on Fire" Part II has a promising lead--using a CTE I can
INSERT my DELETEd rows into a temp table and then EXPORT its contents.
That'll solve my isolation issues, but at the expense of INSERTing
into a table (I'd likely use a DGTT though, so the insertion cost
should be minimal).

I have never tried this, but export this query:
SELECT * FROM OLD TABLE(DELETE FROM T ...)

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks for your reply, Serge. This issue is that the delete is in a
loop, as it deletes in chunks of 200K, so I'd end up having to do a
separate EXPORT for every iteration of the loop to capture all rows
deleted. I think the technique of yours that I refer to above will
work, though.

--Jeff

May 8 '07 #4
On May 8, 2:24 am, jefftyzzer <jefftyz...@sbcglobal.netwrote:
On May 7, 5:45 pm, Serge Rielau <srie...@ca.ibm.comwrote:
jefftyzzer wrote:
Serge's "SQL on Fire" Part II has a promising lead--using a CTE I can
INSERT my DELETEd rows into a temp table and then EXPORT its contents.
That'll solve my isolation issues, but at the expense of INSERTing
into a table (I'd likely use a DGTT though, so the insertion cost
should be minimal).
I have never tried this, but export this query:
SELECT * FROM OLD TABLE(DELETE FROM T ...)
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Thanks for your reply, Serge. This issue is that the delete is in a
loop, as it deletes in chunks of 200K, so I'd end up having to do a
separate EXPORT for every iteration of the loop to capture all rows
deleted. I think the technique of yours that I refer to above will
work, though.

--Jeff


Can you explain why simply performing a single export first, followed
by multiple deletes is unsuitable?

If the table format is such that comma-delimited export output is
feasible, then you could script matching
export and delete commands (creating multiple exported files that you
could later concatenate).
May 8 '07 #5
mike wrote:
Can you explain why simply performing a single export first, followed
by multiple deletes is unsuitable?

If the table format is such that comma-delimited export output is
feasible, then you could script matching
export and delete commands (creating multiple exported files that you
could later concatenate).
Good idea. Simply pipe the pretty printed result set to file.

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
May 8 '07 #6
On May 8, 1:57 am, mike <_lin...@yahoo.comwrote:
On May 8, 2:24 am, jefftyzzer <jefftyz...@sbcglobal.netwrote:


On May 7, 5:45 pm, Serge Rielau <srie...@ca.ibm.comwrote:
jefftyzzer wrote:
Serge's "SQL on Fire" Part II has a promising lead--using a CTE I can
INSERT my DELETEd rows into a temp table and then EXPORT its contents.
That'll solve my isolation issues, but at the expense of INSERTing
into a table (I'd likely use a DGTT though, so the insertion cost
should be minimal).
I have never tried this, but export this query:
SELECT * FROM OLD TABLE(DELETE FROM T ...)
Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Thanks for your reply, Serge. This issue is that the delete is in a
loop, as it deletes in chunks of 200K, so I'd end up having to do a
separate EXPORT for every iteration of the loop to capture all rows
deleted. I think the technique of yours that I refer to above will
work, though.
--Jeff

Can you explain why simply performing a single export first, followed
by multiple deletes is unsuitable?

If the table format is such that comma-delimited export output is
feasible, then you could script matching
export and delete commands (creating multiple exported files that you
could later concatenate).- Hide quoted text -

- Show quoted text -
If a user inserts a row after my single EXPORT that I later delete (in
the next step), then I've deleted something I've not archived.

As I mentioned earlier, I have an approach: create a DGTT, insert into
the DGTT the rows I delete (again, in multiple passes) using two
modifying table functions (one for the DELETE the other for the
INSERT), export the contents of the DGTT.

--Jeff

May 8 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Mike MacSween | last post by:
My client has an MS Access database application on her local machine. I have full access to that in terms of changing the design. I've got a simple PHP/MySql application on shared hosting, so no...
1
by: steve | last post by:
hi, during a full export of my export of a (Release 9.2.0.4.0 - Production ) database i'm getting the following: I have been thru metalink, and can find nothing that is exactly the same, even...
1
by: Bridget Willey | last post by:
I am using ACT 6 and am trying to "split" the database between records for customers and junk records. The accounts designated as "customers" have that word in the ID field, and I am using that...
1
by: Danny | last post by:
Is there a way to use the DoCmd.TransferText to export a database to a text file but with leaving a field out? I need the ID field to do one sort before I export. the spec does not let me...
1
by: Kevin Blakeley | last post by:
I know this was just posted but I did not want this message to get lost in the other thread as it's slightly different. Yes I want to export my dataset to excel for my clients, but I don't want...
0
by: Henry | last post by:
I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that uses MS Access 2000 as its database. I can export reports that have no linked sub reports for printing. However, I'm unable...
2
by: David Richards | last post by:
Hi, I was wondering if anyone could help me. I have DataSet that contains the following data tables Customers, Calls, Quotes, QuoteDetails, Competitors, Contacts, Notes, and I have setup...
17
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and...
1
by: DennisBetten | last post by:
First of all, I need to give some credit to Mahesh Chand for providing me with an excellent basis to export data to excel. What does this code do: As the title says, this code is capable of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.