BeginUpdate method |
Applies to
TIB_Row
Declaration
Procedure BeginUpdate;
Description
This method causes the data change notifications caused by altering the
values of the associated TIB_Column objects for the row to be delayed until
all of the intended processing to the data of the buffer is complete.
This should be used in the context of a try finally block with the
EndUpdate() method being called regardless of an exception.
Here is some sample code which demonstrates how to use this:
// Given a query, an array of names and an array of values; this routine
// will set all the parameters that match the names. It will use the values
// to decide what kind of parameter it is.
procedure Dol_Set_Query_Parameters
(
query : TIB_Query;
const input_paramNames : array of string;
const input_ParamValues : array of const
);
type
ParamCount_t = Integer;
var
param_i : ParamCount_t;
pName : string;
pValue : TVarRec;
fieldParam : TIB_Column;
begin
with query do begin
Prepared := true;
Params.BeginUpdate;
try
for param_i := 0 to High(input_paramNames) do begin
pName := input_paramNames[param_i];
pValue := input_ParamValues[param_i];
fieldParam := ParamByName(pname);
with pValue do begin
case VType of
vtInteger : fieldParam.AsInteger := VInteger;
vtBoolean : fieldParam.AsBoolean := VBoolean;
vtChar : fieldParam.AsString := VChar;
vtExtended : begin
case fieldParam.SQLType of
Sql_Date : fieldParam.AsDateTime := VExtended^;
Sql_Float,
Sql_DFloat : fieldParam.AsFloat := VExtended^;
Sql_Double : FieldParam.AsDouble := VExtended^;
end;
end;
vtString : fieldParam.AsString := VString^;
vtPChar : fieldParam.AsString := VPChar;
vtAnsiString : fieldParam.AsString := string(VAnsiString);
vtCurrency : fieldParam.AsCurrency := VCurrency^;
else
end;
end;
end;
finally
// Make it so that there is only a single change notification even when
// multiple parameters are modified.
// If RefreshOnParamChange is true then the dataset will be refreshed
// here if it was Active to start with.
Params.EndUpdate( true );
end;
end;
end;