473,378 Members | 1,578 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,378 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 4091
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.