473,499 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

remove large number of rows



I'm DB2 newbie. I need to remove large number of rows from a table.
I don't want to fill up the transaction log space. I have the below
SQL that I feed to the db2 command to repeatly remove a fixed set of
rows until there is no more to remove. However db2 complains about
bad syntax. Can anybody advise how I get it right?

Thanks!

DECLARE rows_deleted INT default 1000;
WHILE rows_deleted 0 DO
delete from rcdb.risk_values rv
where rv.PRODUCT_ID_I in
(select pr.PRODUCT_ID_I from
rcdb.risk_values_status rvs, rcdb.PRODUCTS pr
where rvs.UND_SYM_C = pr.UND_SYM_C
fetch first 1000 rows only);
commit;
get diagnostics rows_deleted = row_count;
END WHILE;
Jul 22 '08 #1
2 3656
On Jul 22, 3:39 pm, "Henry J." <tank209...@yahoo.comwrote:
I'm DB2 newbie. I need to remove large number of rows from a table.
I don't want to fill up the transaction log space. I have the below
SQL that I feed to the db2 command to repeatly remove a fixed set of
rows until there is no more to remove. However db2 complains about
bad syntax. Can anybody advise how I get it right?

Thanks!

DECLARE rows_deleted INT default 1000;
WHILE rows_deleted 0 DO
delete from rcdb.risk_values rv
where rv.PRODUCT_ID_I in
(select pr.PRODUCT_ID_I from
rcdb.risk_values_status rvs, rcdb.PRODUCTS pr
where rvs.UND_SYM_C = pr.UND_SYM_C
fetch first 1000 rows only);
commit;
get diagnostics rows_deleted = row_count;
END WHILE;
You'll have to do it in either a stored procedure or a BEGIN
ATOMIC...END block.

--Jeff
Jul 22 '08 #2
jefftyzzer wrote:
On Jul 22, 3:39 pm, "Henry J." <tank209...@yahoo.comwrote:
>I'm DB2 newbie. I need to remove large number of rows from a table.
I don't want to fill up the transaction log space. I have the below
SQL that I feed to the db2 command to repeatly remove a fixed set of
rows until there is no more to remove. However db2 complains about
bad syntax. Can anybody advise how I get it right?

Thanks!

DECLARE rows_deleted INT default 1000;
WHILE rows_deleted 0 DO
delete from rcdb.risk_values rv
where rv.PRODUCT_ID_I in
(select pr.PRODUCT_ID_I from
rcdb.risk_values_status rvs, rcdb.PRODUCTS pr
where rvs.UND_SYM_C = pr.UND_SYM_C
fetch first 1000 rows only);
commit;
get diagnostics rows_deleted = row_count;
END WHILE;

You'll have to do it in either a stored procedure or a BEGIN
ATOMIC...END block.
Because of the COMMIT it can't be in a dynamic compound (BEGIN ATOMIC)
Anyway: Which version/platform of DB2 and what is the exact syntax error?
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 23 '08 #3

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

Similar topics

2
6795
by: Kevin Crosbie | last post by:
Hi all, (Sorry for the cross-post, there doesn't appear to be much activity on comp.database.oracle)I'm trying to get the last 300 rows from the difference between 2 large tables and my queries...
57
25461
by: Bing Wu | last post by:
Hi all, I am running a database containing large datasets: frames: 20 thousand rows, coordinates: 170 million row. The database has been implemented with: IBM DB2 v8.1
2
2164
by: shsandeep | last post by:
Hi all, I have heard and read this many times: "Partitions should only be used for 'very large' tables". What actually determines whether a table is 'very large' or not? I have tables containing...
24
21504
by: Frank Swarbrick | last post by:
We have a batch process that inserts large numbers (100,000 - 1,000,000) of records into a database each day. (DL/I database.) We're considering converting it to a DB2 table. Currently we have...
2
2424
by: =?Utf-8?B?UHJpeWE=?= | last post by:
Hi, I'm faced with a classic problem of how to update a large number of records from a web page. I;m trying to build an interface that will display recordset in the order of 3000 rows and allow...
3
12302
by: Michel Esber | last post by:
Hello, Environment: DB2 LUW v8 FP15 / Linux I have a table with 50+ Million rows. The table structure is basically (ID - Timestamp). I have two main applications - one inserting rows, and the...
6
7960
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
7
2596
by: abunn | last post by:
I've been learning Visual C++ on the fly at work for the last 2 weeks and could use some help. I'm writing a program to read a .raw file which has a standard format of 9 columns and then depending...
5
8364
by: Henry J. | last post by:
I'm new to DB2. I want to remove large number of rows in a table without filling up the transaction log space. To this end we can repeatedly remove a fixed number of rows followed by commit. In...
0
7130
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
7171
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
7220
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...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.