Delphi Examples: DbiInsertRecord

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiInsertRecord

Return to chapter overview

Append or insert a record on the specified table.

Use the Insert and Post methods on a dataset to insert records. This inserts a new record, contained in pTmpRecBuf, into the table associated with the given cursor. This example uses the following input:

 fDbiInsertRecord(hCursor, RecBuf);

The procedure is:

procedure fDbiInsertRecord(hTmpCur: hDBICur; pTmpRecBuf: pByte);

begin

 Check(DbiInsertRecord(hTmpCur, dbiNOLOCK, pTmpRecBuf));

end;

Insert or append a record to a table.

If the table has an index, insert the record. Most Delphi users should use: TTable.Insert, TTable.Append, TTable.InsertRecord, or TTable.AppendRecord. This example uses the following input:

 fDbiInsertRecord(Table1.Handle, pRecBuf: pBYTE);

The procedure is:

procedure fDbiInsertRecord(hTmpCur: hDBICur; pRec: pBYTE);

var

 Props: CURProps;

begin

 Check(DbiGetCursorProps(hTmpCur, Props));

 // Check to see if there are any active indexes on the table

if (Props.iIndexes > 0) then

 // Insert the record

   Check(DbiInsertRecord(hTmpCur, dbiNOLOCK, pRec))

else

 // Append the record

   Check(DbiAppendRecord(hTmpCur, pRec));

end;