|
<< Click to Display Table of Contents >> Delphi Examples: DbiSetProp |
![]() ![]()
|
Example1: Enable or disable soft deletes.
Set soft deletes to True or False depending on the Boolean parameter SoftDelete in the TTable specified in the Table parameter. This example uses the following input:
fDbiSetProp1(AnimalTbl, True);
The procedure is:
procedure fDbiSetProp1(Table: TTable; SoftDelete: Boolean);
var
rslt: DBIResult;
Props: CURProps;
begin
Check(DbiGetCursorProps(Table.Handle, Props));
if (Props.szTableType <> szDBASE) then
raise EDBEngineError.Create(DBIERR_NOTSUPPORTED);
// Make sure that the property can be set
rslt := DbiValidateProp(hDBIObj(Table.Handle), curSOFTDELETEON, True);
if (rslt = DBIERR_NONE) then
// Set the property
Check(DbiSetProp(hDBIObj(Table.Handle), curSOFTDELETEON, Longint(SoftDelete)))
else
raise EDBEngineError.Create(rslt);
end;
Example 2: Specify the maximum number of rows to be fetched from an SQL statement.
Set the maximum rows fetched in the parameter MaxRows, for the SQL table specified in the Table parameter. This example uses the following input:
fDbiSetProp2(IBTable, 100);
The procedure is:
procedure fDbiSetProp2(Table: TTable; MaxRows: Longint);
var
rslt: DBIResult;
DBType: String;
Len: Word;
begin
SetLength(DBType, DBIMAXNAMELEN);
Check(DbiGetProp(hDBIObj(Table.DBHandle), dbDATABASETYPE,
PChar(DBType), DBIMAXNAMELEN, Len));
SetLength(DBType, StrLen(PChar(DBType)));
// Make sure the table type is not dBASE or Paradox (must be SQL based)
if (DBType = 'STANDARD') then
raise EDBEngineError.Create(DBIERR_NOTSUPPORTED);
// Make sure that the property can be set
rslt := DbiValidateProp(hDBIObj(Table.Handle), curMAXROWS, True);
if (rslt = DBIERR_NONE) then
// Set the property
Check(DbiSetProp(hDBIObj(Table.Handle), curMAXROWS, MaxRows))
else
raise EDBEngineError.Create(rslt);
end;