version 1.5
OP Load record (connectionID; bindID; tableID; lockStatus) Longint
Parameter | Type | Description | |
connectionID | Longint | Connection ID with target server | |
bindID | Longint | Bind list ID | |
tableID | Longint | Number of the table in the database | |
lockStatus | Longint | Lock status = 1 means the record is locked. | |
Function result | Longint | Error 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 Code | Description |
-108 | Not enough memory to perform this operation. |
-9969 | Invalid field type requested. |
-9971 | Field number is out of range. |
-9972 | Table number is out of range. |
4004 | There is no current record in the local table. |
10128 | The 4D Open for 4th Dimension package has not been initialized. |
10136 | The connection does not exist. |
10137 | The bind list does not exist. |
10139 | The bind list is not defined. |
10153 | Unable to convert this type of data. |
10154 | This 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.