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_alllocks() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 AX_AllLocks()
 Returns info about records in the given table that are currently locked
------------------------------------------------------------------------------

Syntax

     AX_AllLocks( <cTableName>, [<cUserName> | <nConnNumber>] ) -> 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.

     <cUserName>   Optional user name.  The user name of an Advantage
                   client is the client computer name.

     <nConnNumber> Optional NetWare connection number.  Only applicable
                   if running against the Advantage Database Server for
                   NetWare.

Returns
     Returns a two dimensional array of information about records in the
     given table that are currently locked on the Advantage Database Server.
     The length of the first dimension of the returned 2-D array will be
     equal to the number of records in the given table that the specified
     user has locked or that are locked by any user.  The second dimension
     of the returned 2-D array has one element containing:

     [n][1] = (number) Record number that is locked

     - or -

     Returns an empty array if an error occurred or no records are
     currently locked. If an error occurred, AX_Error() will return
     information on why the function failed.

Description

     AX_AllLocks() returns a two dimensional array of information about
     records in the given table that the specified user has locked or that
     are locked by any user.  If cUserName contains an Advantage client's
     user name or if nConnNumber is non-zero, then the returned 2-D array
     will contain a list of information about records that are locked in the
     given table by the specified user. If cUserName and nConnNumber are not
     specified or are NIL, then the returned 2-D array will contain a list of
     information about all records that are locked in the given table by any
     user.

     It is possible that the number of elements in the second dimension of
     the returned 2-D array with record information 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 record information that may
     exist if using a newer version of the Advantage Database Server will
     not be returned in the second dimension of the returned 2-D array.

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

     If the specified table name is locked, then the first dimension of the
     returned 2-D array with be of length one.  The record number in that
     lone array element will be 0.

     Note: AX_AllLocks() will only return information about records
     locked on the Advantage Database Server.  Information about any records
     locked by non-Advantage users will not be returned.

Example

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

     // Get all records locked in table "employee.dbf"
     aAllLocks := AX_AllLocks( "x:\employee.dbf" )

     // Get records locked in table "employee.dbf" by user "Fred"
     aLocksByFred := AX_AllLocks( "x:\employee.dbf", "Fred" )

     if ( Len( aAllLocks ) == 0 )
        ? "No records locked"
        quit
     endif

     // Display info about all locks on table employee.dbf
     ? Len( aAllLocks ), "locks exist on table employee.dbf"
     if (( Len( aAllLocks ) == 1 ) .AND. ( aAllLocks[1][1] == 0 ))
        ? "The file is locked"
     else
        ? "The locked records are:"
        for i := 1 to Len( aAllLocks )
           ?
           for j := 1 to Len( aAllLocks[i] )
              ?? aAllLocks[i][j]
           next
        next
     endif

     // Display info about locks on table employee.dbf by Fred
     ? "Fred has ", Len( aLocksByFred ), "locks on table employee.dbf"
     if (( Len( aLocksByFred ) == 1 ) .AND. ;
         ( aLocksByFred[1][1] == 0 ))
        ? "The file is locked by Fred"
     else
        ? "The locked records are:"
        for i := 1 to Len( aLocksByFred )
           ?
           for j := 1 to Len( aLocksByFred[i] )
              ?? aLocksByFred[i][j]
           next
        next
     endif


See Also: AX_UserNames() AX_OpenTables()

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