OP Load record

4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next

version 1.5


OP Load record (connectionID; bindID; tableID; lockStatus) Longint

ParameterTypeDescription
connectionIDLongintConnection ID with target server
bindIDLongintBind list ID
tableIDLongintNumber of the table in the database
lockStatusLongintLock status = 1 means the record is locked.
Function resultLongintError code result for the function

Description

OP Load record loads and tries to lock the current record(s) of the table(s) listed in the bind list. It loads only the data defined in bindID.

For example, if you bind only the first three fields in a table, only the data from these three fields will be loaded, instead of loading all the fields for that record.

If lockStatus returns 0, this means that you have obtained the record(s) in read/write mode and can modify or delete the record(s). If you obtain a record in read/write mode, you must later release it using OP Unload record. This ensures that other users and processes will be able to access the record in read/write mode.

If the record is already in use, or if you accessed the table(s) in read-only mode, lockStatus = 1. If you need to access the current record in read/write mode, you must re-execute OP Load record until lockStatus returns 0 or until you choose to abort the operation you wanted to perform.

OP Load record always returns the values of the fields you requested, regardless of the access mode.

If there is no current record, OP Load record has no effect.

Error Codes

If OP Load record executes successfully, it returns 0. Otherwise, this function returns one of the following errors:

Error CodeDescription
-108Not enough memory to perform this operation.
-9969Invalid field type requested.
-9971Field number is out of range.
-9972Table number is out of range.
4004There is no current record in the local table.
10128The 4D Open for 4th Dimension package has not been initialized.
10136The connection does not exist.
10137The bind list does not exist.
10139The bind list is not defined.
10153Unable to convert this type of data.
10154This command cannot be executed right now.

Example

In this example, the LoadAndLock method attempts to load a record and lock it in order to update it later.

   ` Method LoadAndLock (Conn,TableID;BindID;MaxWait) -> LockStatus
   ` Conn, Connection ID
   ` TableID, number of the table for whitch to load the current record
   ` BindID, bind list ID to be used for loading values
   ` MaxWait, Maximum nuber of lock attempts before returning failure

   C_LONGINT (Conn,TableID,BindID,MaxWait)
   C_LONGINT ($errCode;Lock;$0;$i)

   $Conn := $1
   $TableID := $2
   $BindID := $3
   $MaxWait := $4
   $i := 0
   $Lock:=0
   
   ` Set access mode to read write so that next load operation will attempt to lock the record
   $errCode := OP Set access mode (Conn;TableID;1)

   Repeat
      $errCode:= OP Load record ($Conn;$TableID;$BindID;$Lock)
      If ( ($i<=$maxWait) & ($lock=1) )
         ` If the record is locked by another process, and we have some attempts left
         DELAY PROCESS (Current process;15) `Sleep 1/4 of a second
      End if
      $ i:= $i + 1 
   Until ( ($i >=$maxWait) | ($lock = 0) )

   ` Return lock status
   $0 := $lock

See Also

OP Goto selected record, OP Set access mode, OP Unload record.


4D - Documentation   Français   English   German   4D Open for 4D, Command Theme List   4D Open for 4D, Command Alphabetical List   Back   Previous   Next