Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: several process collide when updating one table

Re: several process collide when updating one table

From: Colin McKinnon <colin_at_EditMeOutUnlessYoureABot.wew.co.uk>
Date: Tue, 31 Jul 2001 10:16:43 +0100
Message-ID: <3ss5k9.cnk.ln@Lonmay.wew.co.uk>

M. Weiss <weiss_at_virtual7.de> wrote in message news:3b65ac18$1_at_netnews.web.de...
> Ok... the problem which occurred was, that during selecting and updating
 from
> one process, a second process selected the same item and did also his job
 with
> that row. So I decided to go another way:
>

The first thing to do is to identify whether you need to update records one at a time. Using SQL to update a set of records is far more efficient and a LOT faster. You'll also be able to use locking to solve your problem.

If you can enumerate your processes (i.e. give them each a unique sequential number starting at 0) then you can preflag all the records for each process (can't remember how oracle does modulo - using % in below) e.g.

    UPDATE myrecords SET processor = rownum % $max_number_of_proc;

Then instead of selecting all records, select those which have been preflagged for the process:

    SELECT * FROM myrecords WHERE procesor = $proc_enum;

Preflagging a single record isn't going to much help.

HTH Colin Received on Tue Jul 31 2001 - 04:16:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US