rec_kill()

Purpose

Deletes a record from a database

Old name

#define kill rec_kill

Syntax (CCOWN)

void rec_kill(short *datarec, int flags)

Syntax (DP4DBAPI)

BOOLEAN dp4_rec_kill(DCONN * dconn,short * datarec,int flags);

Parameters

DCONN * dconn

Handle to a database connection

 

short* datarec

Pointer to the L field of the database record to be deleted

 

int flags

Indicates what checks should be made

 

The parameter flags can take a combination of the following values:

 

Value

Meaning

 

ORPHAN_CHECK

The transaction will fail with fail_code ORPHAN_CHECK if any orphans would be left in the tables that have this table as a parent, if the index is marked for orphan checking. This test is also made for any children which would be deleted by the CHILD_DELETE option if the CHILD_DELETE flag is not specified. This flag is useful if you want to do things such as preventing a customer record being deleted while there are still outstanding orders for him.

 

CHILD_DELETE

All children in tables that have this table as a parent, and have the index marked for child deletion will be killed. This rule is applied recursively, so that the grandchildren and so on are also killed. This flag is useful for doing things like deleting an order record together with all its order lines.

 

IGNORE_CHILD or NO_CHECK

This should be passed if neither ORPHAN_CHECK nor CHILD_DELETE are desired. No orphan checking or child deletion is done. It is your responsibility to ensure database consistency is maintained by performing your own orphan checking and deleting child records that shold be deleted.

 

NO_UPD_CHILD

This flag can improve performance when the CHILD_DELETE flag is used in programs that opened the database with the PRIVATE_DB flag. In such programs rec_kill() will normally add all the child records that would be deleted because of the CHILD_DELETE flag to the post workfile as deleted. This is so that a later call to rec_fetch() for one of these records will know that the record is deleted. If you won't be calling rec_fetch() on the child records, or don't mind that they will be returned even though they will be deleted by the following commit() then passing this flag will speed up deletion considerably.

 

Additionally the value NO_FINDLIST can be added to the flag, as with the function rec_post_with_flags()

Description

The rec_kill() function deletes the record specified by the datarec parameter from the database. A call to either db_commit(), db_checkpoint() or db_update() is required to make the deletion permanent.

Until one of these functions is called, the record may still be read from the database by calls to rec_fetch() unless the database has been opened with the flag PRIVATE_DB. For dp4_rec_kill() the return value is TRUE if the function completes without errors. This does not indicate anything about the eventual success or failure of the transaction

See also

rec_post_with_flags(), db_commit(), db_checkpoint()

Example

rec_kill(&order,NO_CHECK);