FILELOCK/FILEUNLOCK

 

COMMAND SYNTAX

FILELOCK filevar {LOCKED statements} {ON ERROR statements}

FILEUNLOCK filevar {ON ERROR statements}

 

DESCRIPTION

When the FILELOCK statement is executed, it will attempt to take an exclusive lock on the entire file. If there are any locks currently outstanding on the file, then the statement will block until there are no more locks on the file. The use of the LOCKED clause allows the application to perform an unblocked operation.

When the FILELOCK statement is blocked waiting for a lock, other processes may continue to perform database operations on that file, including the removal of record locks and also the taking of record locks.

Once the FILELOCK is taken , it will block ALL database accesses to the file whether or not the access involves record locks. i.e. a READ will block once a FILELOCK has been executed, as will READU , READL , WRITE , CLEARFILE and so on.

The lock continues until either the file is closed, the program terminates or a FILEUNLOCK statement is executed

 

IMPLEMENTATION NOTES

The FILELOCK command is implemented using the native locking mechanism of the operating system and is entirely at its mercy. Because of this you may see some slight implementation differences between operating systems. These comments on native locking do not apply to the NT platform as jBASE will always use the NT locking mechanism.

The use of the native (UNIX) locking mechanism means the file in question MUST NOT use the jBASE locking mechanism. You can set a file to use the native locking mechanism by using the jchmod command like this :

jchmod +N filename {filename ...}

or like this when the file is originally created:

CREATE-FILE filename 1,1 23,1 NETWORK=TRUE

If the file continues to use jBASE record locking then the ON ERROR clause will be taken and the SYSTEM(0) and STATUS() functions will be set to 22 to indicate the error.


jBC