DbiDeleteRecord

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

DbiDeleteRecord

Return to chapter overview

C syntax

DBIResult DBIFN DbiDeleteRecord (hCursor, [pRecBuf]);

Delphi syntax

function DbiDeleteRecord (hCursor: hDBICur; pRecBuf: Pointer): DBIResult stdcall;

Description

DbiDeleteRecord deletes the current record of the given cursor.

Parameters

hCursor                Type: hDBICur                (Input)
Specifies the cursor handle.

pRecBuf                Type: pBYTE                (Output)
Pointer to the client buffer that receives the deleted record. Optional.

Usage

dBASE and FoxPro: DbiDeleteRecord marks the record for deletion. The record is not physically removed from the table until the table is packed with DbiPackTable.

Paradox: After a record is deleted and committed, it cannot be recalled. The record is not deleted if the deletion would cause violation of referential integrity. For example, if the cursor is validly positioned on a record within the master table, and that record has linked values in a detail table, then the call to DbiDeleteRecord fails, and the position of the cursor remains unchanged.

Deleting a record does not reduce table size. The only way to gain disk space for records that have been deleted is to restructure the table with a call to DbiDoRestructure.

Access: After a record is deleted and committed, it cannot be recalled. The record is not deleted if the deletion would cause violation of referential integrity. For example, if the cursor is validly positioned on a record within the master table, and that record has linked values in a detail table, then the call to DbiDeleteRecord fails, and the position of the cursor remains unchanged.

SQL: Record deletions are done via optimistic locking. Unless a transaction is explicitly started using DbiBeginTran, a successful deletion is immediately committed.

Prerequisites

The cursor must be positioned on a record, not on a crack, beginning of file, or end of file. The user must have read/write access to the table. The record must not be locked by another session.

Completion state

After DbiDeleteRecord has successfully completed, the cursor is positioned on the crack between the records before and after the deleted record. A subsequent call to DbiGetNextRecord returns the record after the deleted record, while a subsequent call to DbiGetPriorRecord returns the record before the deleted record.

DbiResult

Meaning

DBIERR_NONE

The record was successfully deleted.

DBIERR_INVALIDHNDL

The specified cursor handle is invalid or NULL.

DBIERR_BOF

The cursor is not positioned on a record.

DBIERR_EOF

The cursor is not positioned on a record.

DBIERR_KEYORRECDELETED

The cursor is not positioned on a record.

DBIERR_NOCURRREC

The cursor is not positioned on a record.

DBIERR_RECLOCKED

The record or table is locked by another session.

DBIERR_NOTABLESUPPORT

A deletion cannot be made from a view. Some SQL drivers do not support deletions from non-uniquely indexed tables.

DBIERR_TABLEREADONLY

Table access denied; the cursor does not have write access to the table.

DBIERR_DETAILRECORDSEXIST

The table is the master table in a referential integrity link and the record to be deleted has associated detail records (Paradox only).

DBIERR_NOTSUFFTABLERIGHTS

Insufficient table rights to delete a record (Paradox only).

DBIERR_NOTSUFFSQLRIGHTS

Insufficient SQL rights to delete a record (SQL only).

DBIERR_MULTIPLEUNIQRECS

Attempt to delete a record that has a duplicate (SQL only).

See also

DbiGetRecord, DbiDoRestructure, DbiGetNextRecord, DbiGetPriorRecord, DbiGetRelativeRecord, DbiPackTable (dBASE and FoxPro only), DbiUndeleteRecord (dBASE and FoxPro only)