Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: cursor/update freezes
In article <953211533.174983_at_newsreader2.wirehub.nl>, Thomas Sjoerdsma
<t_sjoerdsma_at_hotmail.com> writes
>Hi
>
>i use the following cursor/update methode but the system freezes while
>running the program in wich this sql is embedded.
>Does anybody have an idea why????
>
>Thanks
>
>EXEC SQL WHENEVER NOT FOUND DO break;
>EXEC SQL DECLARE emp_cursor CURSOR FOR SELECT AMOUNT FROM SYS.BP_DECO WHERE
>DEALER_ID = :searchkey FOR UPDATE OF AMOUNT;
> EXEC SQL OPEN emp_cursor;
> for(;;) {
> EXEC SQL FETCH emp_cursor INTO :mamount;
> EXEC SQL UPDATE SYS.BP_DECO SET AMOUNT = 10
> WHERE CURRENT OF emp_cursor;
> }
> EXEC SQL CLOSE emp_cursor;
> EXEC SQL COMMIT;
>
>
>
The FOR UPDATE clause will lock *all* eligible rows before the first row is returned. Perhaps you're getting some lock contention?
Andy
--
Andy Hardy. PGP key available on request