Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > Update Statemen...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 8876 of 9053
Post > Topic >>

Update Statement and frequent commits

by Michel Esber <michel@[EMAIL PROTECTED] > May 11, 2008 at 09:54 AM

Hello,

DB2 v8 FP15 luw.

Serge=B4s SQL on Fire has the following code for granular commits on
delete statements:

loop: LOOP
    DELETE FROM  (SELECT 1 FROM T WHERE ID =3D ? FETCH FIRST 1000 ROWS
ONLY) AS D;
    IF SQLCODE =3D 100 THEN LEAVE loop;
    END IF;
  COMMIT;
END LOOP loop;


I want to achieve the same for Update statements on multi million
tables. My first try is:


loop: LOOP
	update from T where ID IN

	(
	select ID from
	 (select ID, rownumber() over (partition by ID order by ID desc) as
RN from T where ID =3D ? ) as x
	where rn <=3D 1000
	)

    IF SQLCODE =3D 100 THEN LEAVE loop;
    END IF;
  COMMIT;
END LOOP loop;



Any better suggestion or approach ?

Thanks, Michel




 3 Posts in Topic:
Update Statement and frequent commits
Michel Esber <michel@[  2008-05-11 09:54:44 
Re: Update Statement and frequent commits
Michel Esber <michel@[  2008-05-11 18:12:30 
Re: Update Statement and frequent commits
Serge Rielau <srielau@  2008-05-11 21:56:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 18:32:34 CDT 2008.