Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 12 total
Thread About locks
Tue, Aug 5 2008 3:18 AMPermanent Link

Francisco Fernandez
Hi

I have a transaction that updates a record but if in another client have locked this
record by software the transaction don't update it and it not emite any message of error.

Can i controle it?

Thank you
Tue, Aug 5 2008 6:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Francisco,

<< I have a transaction that updates a record but if in another client have
locked this record by software the transaction don't update it and it not
emite any message of error. >>

That doesn't sound right at all - you should at least get a row lock error
if you try to edit/delete/lock a row that is already locked by another
session.  Are you using the default pessimstic row locking protocol ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Aug 5 2008 6:50 AMPermanent Link

Francisco Fernandez
Tim

Yes, i'm using pessimistic record lock. The issue is that i have an record locked with an
edit by a TedbTable component, at the same time another client shoot a trigger that must
update this record and it not update this locked record without error. This trigger
contains a transaction within the sql code to update the record.
Tue, Aug 5 2008 7:05 AMPermanent Link

Francisco Fernandez
wait....

I will revise the trigger, i'll notice to you
Tue, Aug 5 2008 7:38 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Francisco,

<< Yes, i'm using pessimistic record lock. The issue is that i have an
record locked with an edit by a TedbTable component, at the same time
another client shoot a trigger that must update this record and it not
update this locked record without error. This trigger contains a transaction
within the sql code to update the record. >>

So, you are receiving an error ?   If so, then you simply need to trap the
error with a BEGIN..EXCEPTION block in the trigger and then loop and retry
the update until it succeeds, or re-raise the exception, like this:

BEGIN
  WHILE TRUE DO
     BEGIN
        -- Try update here
        LEAVE;  -- If it succeeds, then just leave the WHILE block
     EXCEPTION
        IF ERRORCODE() <> 1005 THEN
           RAISE;
     END;
  END WHILE;
END

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Aug 5 2008 7:55 AMPermanent Link

Francisco Fernandez
Great, this is what i wanted.

Thank you
Tue, Aug 5 2008 8:08 AMPermanent Link

Francisco Fernandez
ummmmmmm.... this is my trigger but i can't save it, where are the fail?


BEGIN
 DECLARE TempCursor CURSOR FOR stmt;
 DECLARE TempCantidad DECIMAL(12,2);        
 WHILE TRUE DO BEGIN
   START TRANSACTION ON TABLES Proveedores;
   BEGIN
     PREPARE stmt FROM 'SELECT * FROM Proveedores WHERE CODIGO COLLATE ESP_CI=?';
     OPEN TempCursor USING NEWROW.PROVEEDOR;
     FETCH FROM TempCursor (TOTALC) INTO TempCantidad;
     If TempCantidad IS NULL THEN
       UPDATE TempCursor SET TotalC=NEWROW.TOTALBASE;
     ELSE
       UPDATE TempCursor SET TotalC=TempCantidad+NEWROW.TOTALBASE;
     END IF;
     UPDATE TempCursor SET FECHAULTC=NEWROW.FECHA;
     COMMIT;
     LEAVE;
   EXCEPTION
     IF ERRORCODE() <> 1005 THEN
       RAISE;
     END IF;
   END;
 END WHILE;
END
Tue, Aug 5 2008 8:20 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Francisco,

<< ummmmmmm.... this is my trigger but i can't save it, where are the fail?
>>

Are you modifying this in the ElevateDB Manager ?  It should put the cursor
on the line where the error is.

What is the error message that you're seeing ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Aug 5 2008 8:22 AMPermanent Link

Francisco Fernandez
Line 25 column 7
Expected ; but instead found WHILE
Tue, Aug 5 2008 8:31 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Francisco,

<< Line 25 column 7
Expected ; but instead found WHILE >>

Thanks.   Get rid of this BEGIN:

 WHILE TRUE DO BEGIN  <<<<<

so that it just says:

 WHILE TRUE DO

You've essentially got one too many BEGINs.

--
Tim Young
Elevate Software
www.elevatesoft.com

Page 1 of 2Next Page »
Jump to Page:  1 2
Image