update statement [message #384360] |
Tue, 03 February 2009 08:56 |
jinga
Messages: 116 Registered: January 2003
|
Senior Member |
|
|
I am running the below code. it takes 3 hours to run. bp table has 400000 rows. ICP has 12 million rows.
declare
i integer;
begin
for i in ( select distinct item_sid from bp)
loop
UPDATE ICP b
SET BP_EFF_IRM = (Select base_eff_irm
From BP a
Where a.item = b.item and
a.tree = b.tree and
a.cell = b.cell and
a.map_eff_irm = b.map_eff_irm and
b.mth between a.base_eff_irm and a.base_end_irm)
where b.item = i.item;
commit;
end loop;
end;
Anu
|
|
|
|
|
Re: update statement [message #384367 is a reply to message #384360] |
Tue, 03 February 2009 09:06 |
cookiemonster
Messages: 13960 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I doubt that since the code you've posted won't actually compile - i.item definitely doesn't exist.
That said a couple of basic points.
1) i integer - huh?
If you're doing
FOR <something> IN <SELECT> LOOP
that something is a record not an integer and you don't need to declare it.
2) Commiting inside loops is a really bad idea.
3) This would perform a lot better written as a single update statement, but for the amount of data you appear to be updating it's never going to be fast.
|
|
|
|