A WRITE automatically clears the lock, a WRITEU will keep it. If you are inside 
a transaction boundary however, then the lock is kept until the transaction is 
committed or abandoned.

Regards
JayJay



On 7 Feb 2013, at 20:46, Jon Wells <[email protected]> wrote:

> What I'm wondering is; what can I put into the 'Xxx what to do if locked' 
> section whereby it waits until the record lock clears, once it clears, set my 
> own lock, read the record, alter the record, and then write the record (which 
> would release my lock)?
> 
> 
> Thank you,
> 
> Jon Wells
> 
> 
> ________________________________
> From: "Woodward, Bob" <[email protected]>
> To: U2 Users List <[email protected]> 
> Sent: Thursday, February 7, 2013 12:35 PM
> Subject: Re: [U2] Record locks (Unidata 7.2)
> 
> Sorry Mecki but I think you have the LOCKED in the wrong place.  At
> least in my version of Unidata.  It comes before the THEN segment so the
> full, proper syntax would be:
> 
> READU xxx FROM xxx, xxx ON ERROR
>   Xxx what to do if a hard error like file not open
> END LOCKED
>   Xxx what to do if locked
> END THEN
>   Xxx what to do if lock is obtained and record is read
> END ELSE
>   Xxx what to do if lock is obtained but record does not exist.
> END
> 
> There is a second format for the READU command but it's a lot easier if
> the OP just reads about, himself, in the HELP information.  HELP
> UNIBASIC READU from ECL in Unidata will get him that.
> 
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Mecki
> Foerthmann
> Sent: Thursday, February 07, 2013 12:27 AM
> To: [email protected]
> Subject: Re: [U2] Record locks (Unidata 7.2)
> 
> The READU statement has a LOCKED clause that is true if a record is
> locked.
> You can put all your locking ha logic in there.
> READU record FROM filevariable,itemID THEN
>     code if record exists and isn't locked (optional) LOCKED
>     code to handle locked record condition (optional) END ELSE
>     code if record doesn't exist (required) END
> 
> Now if you put that into a loop you can display a message and give the
> user the option to try again or abort.
> And if you put the code into a subroutine you can use that in all your
> programs with a single line like this.
> CALL SR.READU(record,filevariable,ItemID,Option,Err)
> 
> On 06/02/2013 21:52, Jon Wells wrote:
>> Hi all,
>> 
>> I have not looked at the world of record locks since my R83 Pick days.
> I'm hoping to add the ability for the program I'm working on to:
>> 
>>     * Check if a record is locked
>>     * Wait until the lock is removed
>>     * Once the lock is removed, or if the record is not locked:
>>     * Lock the record
>>     * Perform the WRITE statement
>> I'm hoping someone can share an example of how to accomplish this in
> UniBasic. 
>> 
>> 
>> Thank you,
>> 
>> 
>> Jon Wells
>> Campbell University
>> _______________________________________________
>> U2-Users mailing list
>> [email protected]
>> http://listserver.u2ug.org/mailman/listinfo/u2-users
> 
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to