how to lock a set of records?

how to lock a set of records?

Post by joe » Fri, 12 Oct 2001 13:35:46



I usually use these statements to get a perpetual lock on a single record
without initiating a transaction.

DO TRANSACTION:
  FIND ----- EXCLUSIVE-LOCK NO-ERROR.
END.

I kinda need to do the same thing, but this time, I need to lock all the
records that is return by a certain query. Apparently, the QUERY PRESELECT
with EXCLUSIVE-LOCK statement only locks the current record in the buffer.

I'm also trying to find out how to lock entire table. Can I use the hidden
file to do this?

Thanks,
Joe

 
 
 

how to lock a set of records?

Post by john » Sat, 13 Oct 2001 09:25:46


I would think the following would work:
    DO TRANSACTION:
        FOR EACH xxxx EXCLUSIVE-LOCK:
        END. /* for each */
    END. /* TRANSACTION */

I will assume (but could be wrong) that anything inside the DO block will
keep a lock because the lock would remain in case you had to UNDO the entire
transaction.  Just be carefull of WHOLE-INDEX searches and possibly
overflowing the lock table with too large a record set (pre-V9??).  Also
test test test to make sure it works.

john


Quote:> I usually use these statements to get a perpetual lock on a single record
> without initiating a transaction.

> DO TRANSACTION:
>   FIND ----- EXCLUSIVE-LOCK NO-ERROR.
> END.

> I kinda need to do the same thing, but this time, I need to lock all the
> records that is return by a certain query. Apparently, the QUERY PRESELECT
> with EXCLUSIVE-LOCK statement only locks the current record in the buffer.

> I'm also trying to find out how to lock entire table. Can I use the hidden
> file to do this?

> Thanks,
> Joe

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

how to lock a set of records?

Post by joe » Tue, 16 Oct 2001 13:53:04


Won't work because it will go out of scope. I need a way to lock the records
through out the life of the procedure without scoping the whole procedure as
a transaction.


> I would think the following would work:
>     DO TRANSACTION:
>         FOR EACH xxxx EXCLUSIVE-LOCK:
>         END. /* for each */
>     END. /* TRANSACTION */

> I will assume (but could be wrong) that anything inside the DO block will
> keep a lock because the lock would remain in case you had to UNDO the
entire
> transaction.  Just be carefull of WHOLE-INDEX searches and possibly
> overflowing the lock table with too large a record set (pre-V9??).  Also
> test test test to make sure it works.

> john



> > I usually use these statements to get a perpetual lock on a single
record
> > without initiating a transaction.

> > DO TRANSACTION:
> >   FIND ----- EXCLUSIVE-LOCK NO-ERROR.
> > END.

> > I kinda need to do the same thing, but this time, I need to lock all the
> > records that is return by a certain query. Apparently, the QUERY
PRESELECT
> > with EXCLUSIVE-LOCK statement only locks the current record in the
buffer.

> > I'm also trying to find out how to lock entire table. Can I use the
hidden
> > file to do this?

> > Thanks,
> > Joe

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

how to lock a set of records?

Post by megaStophole » Wed, 17 Oct 2001 00:30:46


Here's some suggestions to locking 'multiple' records:
1. Consider that you REALLY need to do this : if there's a reason to lock
multiple records at one, perhaps there is a deeper issue at work (Schema/App
design).

2. DynBuffers/Querys : create a new dynbuffer, for each record you need
locked, and use a dynquery to lock it.

3. use a Logical lock : add a field that all the procs read prior to
locking.  If it's in use, they can't lock it.

I'm not sure that using the lock table, or locking the whole table is to
your advantage in anyway.

--
'les


> Won't work because it will go out of scope. I need a way to lock the
records
> through out the life of the procedure without scoping the whole procedure
as
> a transaction.



> > I would think the following would work:
> >     DO TRANSACTION:
> >         FOR EACH xxxx EXCLUSIVE-LOCK:
> >         END. /* for each */
> >     END. /* TRANSACTION */

> > I will assume (but could be wrong) that anything inside the DO block
will
> > keep a lock because the lock would remain in case you had to UNDO the
> entire
> > transaction.  Just be carefull of WHOLE-INDEX searches and possibly
> > overflowing the lock table with too large a record set (pre-V9??).  Also
> > test test test to make sure it works.

> > john



> > > I usually use these statements to get a perpetual lock on a single
> record
> > > without initiating a transaction.

> > > DO TRANSACTION:
> > >   FIND ----- EXCLUSIVE-LOCK NO-ERROR.
> > > END.

> > > I kinda need to do the same thing, but this time, I need to lock all
the
> > > records that is return by a certain query. Apparently, the QUERY
> PRESELECT
> > > with EXCLUSIVE-LOCK statement only locks the current record in the
> buffer.

> > > I'm also trying to find out how to lock entire table. Can I use the
> hidden
> > > file to do this?

> > > Thanks,
> > > Joe

> > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> > -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

how to lock a set of records?

Post by William Wyatt-Low » Wed, 17 Oct 2001 02:18:12


At the start of your processing, all you need is :-

DO TRANSACTION:
        find record-you-want-to-lock exclusive-lock.
END.

carry on ....

This will leave the record in a share-locked state - but not in a
transaction.  Find as many records as your lock table will allow.

HTH



>Won't work because it will go out of scope. I need a way to lock the records
>through out the life of the procedure without scoping the whole procedure as
>a transaction.



>> I would think the following would work:
>>     DO TRANSACTION:
>>         FOR EACH xxxx EXCLUSIVE-LOCK:
>>         END. /* for each */
>>     END. /* TRANSACTION */

>> I will assume (but could be wrong) that anything inside the DO block will
>> keep a lock because the lock would remain in case you had to UNDO the
>entire
>> transaction.  Just be carefull of WHOLE-INDEX searches and possibly
>> overflowing the lock table with too large a record set (pre-V9??).  Also
>> test test test to make sure it works.

>> john



>> > I usually use these statements to get a perpetual lock on a single
>record
>> > without initiating a transaction.

>> > DO TRANSACTION:
>> >   FIND ----- EXCLUSIVE-LOCK NO-ERROR.
>> > END.

>> > I kinda need to do the same thing, but this time, I need to lock all the
>> > records that is return by a certain query. Apparently, the QUERY
>PRESELECT
>> > with EXCLUSIVE-LOCK statement only locks the current record in the
>buffer.

>> > I'm also trying to find out how to lock entire table. Can I use the
>hidden
>> > file to do this?

>> > Thanks,
>> > Joe

>> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

-----------------------------------------------------------
William Wyatt-Lowe         Phone:  +44(0)1442 247372
7 East Street              Fax:    +44(0)1442 264447

HP2 5BN    UK              Tailored Business Solutions
-----------------------------------------------------------
If it ain't broke - don't fix it