Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Advantage CA-Clipper Guide v6.11 - ax_lockowner() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 AX_LockOwner()
 Returns the user that has the given record locked in the given table on the
 Advantage Database Server
------------------------------------------------------------------------------

Syntax

     AX_LockOwner( <cTableName>, <nRecordNumber>, <nLockType> ) -> array

     <cTableName>    Table name.  cTableName must include a fully
                     qualified path to that file, i.e. it must contain a
                     drive letter and path or must contain a UNC path which
                     includes the server name and volume/share.

     <nRecordNumber> Record number that is locked or zero.  If zero, then
                     will only check for a table lock on the given table.

     <nLockType>     Returned value indicates if the specified record is
                     locked (ADS_MGMT_RECORD_LOCK (2)), the specified table
                     is locked (ADS_MGMT_FILE_LOCK (3)), or if no lock
                     exists on the given record or table (ADS_MGMT_NO_LOCK
                     (1)). Note that this is an output parameter.  It must be
                     passed by reference (i.e. a `@' must precede the actual
                     parameter).

Returns
     Returns an array of information about the user who has the specified
     record/table locked on the Advantage Database Server.  The two element
     array contains:

     [1] = (string) Name of the user with the record/table locked
     [2] = (numeric) NetWare connection number of the user who has the
           record/table locked

     - or -

     Returns an empty array if an error occurred or if the specified
     record/table is not locked on the Advantage Database Server. If an error
     occurred, AX_Error() will return information on why the function failed.

Description

     AX_LockOwner() returns an array of information about the user who has
     the specified table locked or who has the specified record in the
     specified table locked.  If the table is locked, nLockType will contain
     ADS_MGMT_FILE_LOCK (3).  If the record is  locked, nLockType will
     contain ADS_MGMT_RECORD_LOCK (2).  If the table is not locked or the
     record in the specified table is not locked, an empty array will be
     returned and nLockType will contain the value ADS_MGMT_NO_LOCK (1).

     If nRecordNumber is passed with the value zero, then only the existence
     for a table lock on the specified table will be checked.

     It is possible that the number of elements in the returned user
     information array will increase in future releases of Advantage.  Since
     it is possible to use a newer version of the Advantage Database Server
     with an older version of the Advantage CA-Clipper Client, any new and
     additional user information that may exist if using a newer version of
     the Advantage Database Server will not be returned in the array.

     Since it is possible that the number of elements in the returned user
     information array will increase in future releases of Advantage, it is
     highly recommended that the length of the returned array be calculated
     using the Len() function, rather than hard-coding the expected length to
     a literal value.

     The User Name element (the first element) in the returned array is the
     Advantage client's computer name.

     The Conn Number element (the second element) in the returned array is
     the NetWare connection number for the corresponding user and is
     applicable to the Advantage Database Server for NetWare.  The value
     returned in nConnNumber will be zero if AX_LockOwner() is used with the
     Advantage Database Server for any other OS.

Example

     // Need to include header file for ADS_MGMT_* constants
     #include "DBFCDXAX.CH"

     // Must first get a connection to the Advantage Database Server
     USE x:dummy.dbf VIA "DBFCDXAX"

     // Find out who (if anybody) has record number 89 locked in
     // table employee.dbf.  Note the nLockType parameter is an
     // output parameter and must be passed by reference.
     aLockOwner := AX_LockOwner( "x:employee.dbf", 89, @nLockType )

     // Display the lock owner info
     if ( nLockType == ADS_MGMT_NO_LOCK )
        ? "No file lock exists and record 89 is not locked"
        quit
     elseif ( nLockType == ADS_MGMT_FILE_LOCK )
        ? "A file lock exists on table employee.dbf"
     elseif ( nLockType == ADS_MGMT_RECORD_LOCK )
        ? "A record lock exists on record 89 in table employee.dbf"
     else
        ? "An error occurred getting the lock owner.  The error " +;
          "code is: ", AX_Error()
        quit
     endif

     ? "Information about the owner of the lock is:"
     for i := 1 to Len( aLockOwner )
        ? aLockOwner[i]
     next


See Also: AX_AllLocks()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson