Difference between revisions of "DBF LOCKR()"

From Recital Documentation Wiki
Jump to: navigation, search
Line 1: Line 1:
 
==PURPOSE==
 
==PURPOSE==
Unlock a record
+
Lock a record
  
  
 
==SYNONYM==
 
==SYNONYM==
api_dbf_unlockr()
+
api_dbf_lockr()
  
  
Line 11: Line 11:
 
#include "dbapi.h"
 
#include "dbapi.h"
  
int DBF_UNLOCKR()
+
int DBF_LOCKR(recnum)
  
 
<input parameters>
 
<input parameters>
long recnum; /* Record number */
+
long recnum; /* Record number */
  
<output parameters>
+
<output parameters>
 
none
 
none
 
</code>
 
</code>
Line 22: Line 22:
  
 
==DESCRIPTION==
 
==DESCRIPTION==
The DBF_UNLOCKR() function will unlock the specified record in the currently selected database.
+
The DBF_LOCKR() function will lock the specified record.  A value of -1  will be returned if there is no database open in the current workarea or the specified record number to lock is out of range.
 +
 
 +
The record lock will be issued when no other user has a file lock or the specified record locked.
 +
 
 +
The database will still be opened for shared read/write access for other users however they will not be able to update the record you have locked until you release the record lock.
  
  
 
==EXAMPLE==
 
==EXAMPLE==
The following example locks then unlocks the current record.
+
The following example locks the current record.
  
 
<code lang="c">
 
<code lang="c">
 
#include "dbapi.h"
 
#include "dbapi.h"
  
dbapi_dbf_unlockr()
+
dbapi_dbf_lockr()
 
{
 
{
     int recno;
+
     int locked;
 
+
      
     recno = DBF_RECNO();
+
     if (DBF_ISEXCLUSIVE() == 0 ) {
 
+
      locked = DBF_LOCKR(DBF_RECNO());
     if (!DBF_ISEXCLUSIVE()) DBF_UNLOCKR(recno);
+
    } else {
 +
      locked = -1;
 +
    }
  
     _retni( recno );
+
     _retl( (locked) ? 1 : 0 );
 +
   
 
}
 
}
 
</code>
 
</code>
Line 45: Line 52:
  
 
==SEE ALSO==
 
==SEE ALSO==
[[BLOB_UPDATE()]], [[BLOB_WRITE()]], [[DBF_APPEND()]], [[DBF_DELETE()]], [[DBF_ISEXCLUSIVE()]], [[DBF_ISREADONLY()]], [[DBF_LOCKF()]], [[DBF_RECALL()]], [[DBF_UNLOCKF()]], [[DBF_UPDATE()]], [[FIELD_UPDATE()]], [[MEMO_UPDATE()]], [[MEMO_WRITE()]]
+
[[
 +
BLOB_UPDATE()]], [[BLOB_WRITE()]], [[DBF_APPEND()]], [[DBF_DELETE()]], [[DBF_ISEXCLUSIVE()]], [[DBF_ISREADONLY()]], [[DBF_LOCKF()]], [[DBF_RECALL()]], [[DBF_RECNO()]], [[DBF_UNLOCKF()]], [[DBF_UNLOCKR()]], [[DBF_UPDATE()]], [[FIELD_UPDATE()]], [[MEMO_UPDATE()]], [[MEMO_WRITE()]]
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:SDK]]
 
[[Category:SDK]]

Revision as of 10:25, 30 March 2009

PURPOSE

Lock a record


SYNONYM

api_dbf_lockr()


SYNOPSIS

#include "dbapi.h"
 
int	DBF_LOCKR(recnum)
 
<input parameters>
long	recnum;		/* Record number		*/
 
<output parameters>
none


DESCRIPTION

The DBF_LOCKR() function will lock the specified record. A value of -1 will be returned if there is no database open in the current workarea or the specified record number to lock is out of range.

The record lock will be issued when no other user has a file lock or the specified record locked.

The database will still be opened for shared read/write access for other users however they will not be able to update the record you have locked until you release the record lock.


EXAMPLE

The following example locks the current record.

#include "dbapi.h"
 
dbapi_dbf_lockr()
{
    int 	locked;
 
    if (DBF_ISEXCLUSIVE() == 0 ) {
       locked = DBF_LOCKR(DBF_RECNO());
    } else {
       locked = -1;
    }
 
    _retl( (locked) ? 1 : 0 );
 
}


SEE ALSO

[[ BLOB_UPDATE()]], BLOB_WRITE(), DBF_APPEND(), DBF_DELETE(), DBF_ISEXCLUSIVE(), DBF_ISREADONLY(), DBF_LOCKF(), DBF_RECALL(), DBF_RECNO(), DBF_UNLOCKF(), DBF_UNLOCKR(), DBF_UPDATE(), FIELD_UPDATE(), MEMO_UPDATE(), MEMO_WRITE()