AnyDAC
ContentsIndexHome
PreviousUpNext
TADDataSet.RefreshRecord Method

Rereads field values of the current record from a data source.

Group
Links
Parameters 
Description 
AClearRow: Boolean = True 
When True, then the record fields will be initially erased. 

True, if a record is refreshed. False, if a record is deleted from a dataset.

Use RefreshRecord to discard all changes of the current record and reread it from a data source. A similar method, TDataSet.Refresh, replaces the entire contents of the dataset by re-executing SQL command. 

To reread record the AnyDAC will perform the sequence of steps:

  • If is assigned OnUpdateRecord event handler, then it will be called with ARequest = arFetchRow.
  • If event handler is not assigned or it returns AAction = eaDefault, then:

If query to a data source will return no rows (probably a record is deleted), then when UpdateOptions.RefreshDelete is True a record will be removed from a dataset too, otherwise an exception will be raised. When AClearRow parameters is set to True (default value), then the record will be initially erased. Otherwise the read values will override the corresponding column values. 

The method returns True, if a record is refreshed. And False, if it is deleted from a dataset.

function RefreshRecord(AClearRow: Boolean = True): Boolean;
ADQuery1.UpdateObject := ADUpdateSQL;
// PL/SQL block calling packaged procedure returning customer data by its ID
ADUpdateSQL.FetchRowSQL.Text := 'begin cust_pack.read_cust_data(:new_name, :new_company, :new_state, :old_id); end;';
// always is required to setup output parameters
with ADUpdateSQL.Commands[arFetchRow] do begin
  Params[0].ParamType := ptOutput;
  Params[0].DataType := ftString;
  Params[1].ParamType := ptOutput;
  Params[1].DataType := ftString;
  Params[2].ParamType := ptOutput;
  Params[2].DataType := ftString;
end;
...
ADQuery1.RefreshRecord;
What do you think about this topic? Send feedback!