This function updates an existing record in a file. The list of fields to be updated is specified in a list.
BOOL |
LceUpdate |
(int |
iSession, |
|
|
char far * |
strFieldList, |
|
|
char far * |
strFileName, |
|
|
char far * |
strKeyList, |
|
|
BOOL |
fValidate ) |
Parameters
iSession |
The session identifier as returned by LceGetSessionId. |
strFieldList |
A list of fields to be updated. These fields must have been declared using an LceUseField function. Only the fields specified in this list will be updated. The value for each of the fields in the list must be set using the LceSetFieldValue/LceSetFieldValueU function. |
strFileName |
The name of the file. This file must have been declared using an LceUseFile function. |
strKeyList |
A list of key field names. The fields must have been declared using an LceUseField function. The values for the keys are set using the LceSetFieldValue/LceSetFieldValueU function. Refer to the Notes for the benefits of leaving this key list blank. |
fValidate |
This parameter provides a " check but do not update" facility. True = Perform validate only. False = Perform update immediately. |
Return Values
TRUE is returned if the session has updated or can update the record.
FALSE is returned if an error occurs.
Notes
When multiple users are working with a file, it is likely that two users will want to update the same record at the same time. LANSA Open will handle this situation automatically if you leave the strKeyList blank. In this case, if a user attempts to update a record which has already been changed by another user, LANSA Open issues an appropriate message and does not perform the update.
Because LANSA Open does this check for you, record locking on the host is unnecessary.
If you specify a key, then that record will be updated regardless of whether it has been changed since it was selected.
If you do specify keys, you do not have to use the complete key list. For example, you could use the first two fields in a file with three key fields. You must always use the keys in the correct order. If you use a subset of the key fields, you are implicitly using a "generic select" on the unspecified keys, i.e. match key1 and key2 while key3 can have any value. In this case, you are requesting that all records which match the partial key are updated. If you specify a unique key, you will perform an update of a single record.
Tip
By creating the proper validation rules in the Repository, you can use LANSA to perform referential integrity checks for you. For example, the Repository's rules could specify that an order's details can only be changed if the order flag indicates that the order hasn't already been shipped. The relevant error message can also be stored in the Repository and displayed using LANSA Open's automated error message facility.
Related Functions