6 10 LceDelete

LANSA Open Guide

6.10 LceDelete

Deletes one or more records from the specified file using the specified keys.

BOOL

 LceDelete

(int 

iSession,

 

 

 char far * 

strFileName,

 

 

 char far *

strKeyList,

 

 

 BOOL 

fValidate )

  

Parameters

iSession

The session identifier as returned by LceGetSessionId.

strFileName

The name of the file. The file must have been declared using an LceUseFile function.

strKeyList

A list of key field names. The keys must always be specified in the correct order. These fields must have been declared using the LceUseField function.

You do not have to specify the complete key list. That is, you could list the first two fields in a file which has three key fields, however, 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 deleted.

If you specify a unique key you will perform the delete of a single record.

fValidate

This parameter provides a "check but do not delete" facility, if you wish to check that a record can be deleted before you perform the actual delete.

True = perform the validate only.

False = perform the delete immediately.

  

Return Values

TRUE is returned if the session can delete the record or has deleted the record.

FALSE is returned if an error occurs or the record does not exist.

Notes

When multiple users are working with a file, it is possible that two users will want to delete the same record. LANSA Open will handle this situation automatically if you leave the strKeyList blank. In this case, if a user attempts to delete a record which has already been deleted by another user, LANSA Open issues an appropriate message. Because LANSA Open does this check for you, record locking on the host is unnecessary.

  • This function can only be executed after a session has been opened.

Tip

The LANSA Repository will perform referential integrity checks when deleting records, provided that you have added the relevant validation rules. For example, LANSA can check that a customer has no orders in the order file before allowing the customer record to be deleted from the customer file.

Related Functions

6.71 LceUseFile

6.58 LceSetFieldValue

6.59 LceSetFieldValueU

6.43 LceInsert

6.67 LceUnicodeToHex

6.8 LceCheckFor