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: URGENT: Problem with cursor

Re: URGENT: Problem with cursor

From: Jim Kennedy <kennedy-down_with_spammers_at_no_spam.comcast.net>
Date: Tue, 26 Aug 2003 12:42:25 GMT
Message-ID: <RAI2b.265365$YN5.181846@sccrnsc01>


"Joan Sanchez" <joan.sanchez_at_estamp.es> wrote in message news:bieue8$7co$1_at_nsnmpen2-gest.nuria.telefonica-data.net...
> Hello,
>
> When I execute the following code, the cursor doesn't retreive
> any row, but If I execute the select in svrmgrl a row is retrevied
> to me.
>
> Does anyone know the reason?
>
> Thank you.
>
> Joan Sánchez
>
>
> cursor cLOCK(plILCK baan.ttisfc962998.t$ilck%TYPE, plETID
> baan.ttisfc962998.t$etid%TYPE) is
> select t$item,t$cdad from ttisfc962998 where t$etid<>3 and
> t$ilck=14 and rownum=1;
> sITEM_LOCK baan.ttisfc962998.t$item%TYPE;
> lCDAD_LOCK baan.ttisfc962998.t$cdad%TYPE;
> sITEM_2_LOCK baan.ttisfc962998.t$item%TYPE;
> lCDAD_2_LOCK baan.ttisfc962998.t$cdad%TYPE;
> BEGIN
> update ttisfc962998 set t$ilck=lILCK where t$etid=lETID and
> t$ilck=0;
> if SQL%FOUND then /* Si se modifica devolver un rdo */
> open cLOCK(lILCK,lETID);
> if cLOCK%FOUND then
> fetch cLOCK into sITEM_LOCK, lCDAD_LOCK;
> select t$item, t$cdad into sITEM_2_LOCK,lCDAD_2_LOCK from
> baan.ttisfc962998 where t$etid=lETID;
> if sITEM_2_LOCK <> sITEM_LOCK then /* Como el art es
> diferente -> rollback */
> update baan.ttisfc962998 set t$ilck=0 where
t$ilck=lILCK
> or t$etid=lETID;
> return 3; /* Artículo diferente con 1º et.int.
de
> la secuencia */
> end if;
> if lCDAD_2_LOCK <> lCDAD_LOCK then /* Como la cdad es
> diferente -> rollback */
> update baan.ttisfc962998 set t$ilck=0 where
t$ilck=lILCK
> or t$etid=lETID;
> return 2; /* Cdad diferente con 1º et.int. de la
> secuencia */
> end if;
> return 0; /* Etiq.int. bloqueada y comprobada */
> else
> return 0; /* Al ser la primera etiq.int. y
> bloquearse, se devuelve OK */
> end if;
> else
> update ttisfc962998 set t$ilck=0 where abs(t$ilck)=lILCK;
> return 1;
> end if;
> EXCEPTION
> WHEN others THEN
> return 4;
> END;
>
> FUNCTION UNLOCK_ALL RETURN NUMBER IS
> BEGIN
> update baan.ttisfc967998 set t$ilck=0; -- Etiq.Odettes
LANZADAS
> update baan.ttisfc962998 set t$ilck=0; -- Etiq.Internas
> LANZADAS
> update baan.ttisfc963998 set t$ilck=0; -- Etiq.Internas
> UBICADAS
> update baan.ttisfc964998 set t$ilck=0; -- Etiq.Internas
> PREPARADAS
> RETURN 1;
> EXCEPTION
> WHEN OTHERS THEN
> RETURN 0;
> END;
>
>
>

Oracle recommends not using $ in object names. Also I would use better names and some formatting. If you really want to have something that does "locking" then look at dbms_lock.
Jim Received on Tue Aug 26 2003 - 07:42:25 CDT

Original text of this message

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