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_value s rv
where rv.PRODUCT_ID_I in
(select pr.PRODUCT_ID_I from
rcdb.risk_value s_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;
Comment