Home > Archive > FoxPro database connector > April 2005 > Begin & End Transaction - Delete problem...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Begin & End Transaction - Delete problem...
Debbie

2005-04-07, 8:05 pm

I have a problem deleting records during a Begin and End Transaction.
Basically this is what is happening:

If User1 is viewing a record in MYTABLE at the same time that User2 runs a
procedure to delete a batch of records from MYTABLE then all the records get
deleted except for the one that User1 was looking at. I have tried
including the following code, but it makes no difference!

SELECT mytable
SCAN
IF EXP1 = EXPR2
DO WHILE !RLOCK("mytable")
LOOP
ENDDO
DELETE IN mytable
TABLEUPDATE(0,.T.,"mytable")
UNLOCK IN mytable
ENDIF
ENDSCAN

Could someone please tell me where I am going wrong?

Many thanks - Debbie



Cindy Winegarden

2005-04-07, 8:05 pm

Hi Debbie,

You didn't include the Transaction code in your example. In any case, the
Help on Begin Transaction says:

When you modify records in a table that is part of a transaction, other
users on the network do not have access (read or write) to the records until
you end the transaction.

When other users on the network try to access records you have modified,
they must wait until you end your transaction. They receive the message
"Record not available ... please wait" until the records become available.
Because of this, it is important to keep the length of the transaction to a
minimum or conduct the transaction during times when others do not need
access.
<<


--
Cindy Winegarden MCSD, Microsoft Visual Foxpro MVP
cindy_winegarden@msn
.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden


"Debbie" <britbitz@hotmail.com> wrote in message
news:CtCdnfGNVL14bdD
fRVn-2A@adelphia.com...[color=darkred]
>I have a problem deleting records during a Begin and End Transaction.
> Basically this is what is happening:
>
> If User1 is viewing a record in MYTABLE at the same time that User2 runs a
> procedure to delete a batch of records from MYTABLE then all the records
> get
> deleted except for the one that User1 was looking at. I have tried
> including the following code, but it makes no difference!
>
> SELECT mytable
> SCAN
> IF EXP1 = EXPR2
> DO WHILE !RLOCK("mytable")
> LOOP
> ENDDO
> DELETE IN mytable
> TABLEUPDATE(0,.T.,"mytable")
> UNLOCK IN mytable
> ENDIF
> ENDSCAN
>
> Could someone please tell me where I am going wrong?
>
> Many thanks - Debbie
>
>
>



Olaf Doschke

2005-04-07, 8:05 pm

> DO WHILE !RLOCK("mytable")
> LOOP
> ENDDO


In addition to what Cindy told you, it's
not a good idea to wait for a recordlock
to work, because this locks the application
of User2 until User1 has finished with it's
work on the record.

Simply rollback the transaction and tell
User2 that deleting isn't possible right now,
and he should try again later.

Bye, Olaf.


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com