FireDAC.Comp.DataSet.TFDDataSet.RefreshRecord

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function RefreshRecord(AClearRow: Boolean = True): Boolean;

C++

bool __fastcall RefreshRecord(bool AClearRow = true);

Properties

Type Visibility Source Unit Parent
function public
FireDAC.Comp.DataSet.pas
FireDAC.Comp.DataSet.hpp
FireDAC.Comp.DataSet TFDDataSet

Description

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

Use RefreshRecord to discard all the 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 the SQL command. 

To reread the record, FireDAC performs the following sequence of steps:

  • If the OnUpdateRecord event handler is assigned, then it is called with ARequest having the value of arFetchRow.
  • If the event handler is not assigned or it returns AAction with the eaDefault value, then:

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

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

Example

FDQuery1.UpdateObject := ADUpdateSQL;
// PL/SQL block calling packaged procedure returning customer data by its ID
FDUpdateSQL.FetchRowSQL.Text := 'begin cust_pack.read_cust_data(:new_name, :new_company, :new_state, :old_id); end;';
// Is always required to set up output parameters
with FDUpdateSQL.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;
...
FDQuery1.RefreshRecord;

See Also