EPUB | CHM | PDF

TPSQLDataset.Methods.GetLastInsertID

Top Previous Next

Return an autoincrement field (field updated by sequence) value.

Syntax:

function GetLastInsertID(const FieldNum: integer): integer;

Description:

FieldNum - field number (0-based). Call GetLastInsertID to get an autoincrement field (field updated by sequence) value. If this field is not autoincrement one, GetLastInsertID returns -1.

Example:

For i:=0 to PsqlTable1.FieldCount - 1 do
  Memo1.Lines.Add(Format('Last inserted value for field %s equals to
  %d',[PsqlTable1.Fields[i].FieldName,PSqlTable1.GetLastInsertId(i)]);