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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Get the first non-locked record.

Re: Get the first non-locked record.

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Tue, 20 Nov 2001 23:18:47 GMT
Message-ID: <3bfae495.118302546@news.alt.net>


On Tue, 20 Nov 2001 23:50:38 +0300, "Dmitry E. Loginov" <dmitry_loginov_at_mtu.ru> wrote:

>
>You can try following thing:
>
>declare
> RESOURSE_BUSY exception;
> pragma exception_init(RESOURSE_BUSY,-54);
> cursor C_MAIN is SELECT Id FROM Item WHERE Process IS NULL ORDER BY
>Processing_Order;
> cursor C_LOCK(p_id Item.ID%type) is SELECT id from ITEM
> where ID=p_id and Process IS NULL
> for update nowait;
> R_LOCK C_LOCK%rowtype;
>begin
> for I in C_MAIN loop
> begin
> open C_LOCK(i.id);
> fetch C_LOCK into R_LOCK; -- Try to lock record, exception will be
>raised for the locked recs
> if C_LOCK%found then
> -- Record locked for you; Do something for this one.
> -- Place your code here, for example:
> update Item set Process='processed' where current of C_LOCK;
> end if;
> close C_LOCK;
> exception
> when RESOURSE_BUSY then
> -- Just skip locked record
> if C_LOCK%isopen then close C_LOCK; end if;
> when OTHERS then
> if C_LOCK%isopen then close C_LOCK; end if;
> raise;
> end;
> end loop;
>end;

> when RESOURSE_BUSY then
> -- Just skip locked record
> if C_LOCK%isopen then close C_LOCK; end if;

Why are you checking if C_LOCK%isopen? Isn't that extra. I thought that the EXCEPTION can only be raised when it is open.

Brian Received on Tue Nov 20 2001 - 17:18:47 CST

Original text of this message

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