How to get the id that has just been inserted into the database on the server side, use Delphi XE10.1 SQlServer and Firedac Bank, I would get the id to use in the child table when it is master detail. as shown below
procedure TsrmCadastro.dspPessoaBeforeUpdateRecord(Sender: TObject;
SourceDS: TDataSet; DeltaDS: TCustomClientDataSet; UpdateKind: TUpdateKind;var Applied: Boolean);
var idPessoa : Integer;
begin
if UpdateKind = ukInsert then
begin
if SourceDS = qryPessoa then
Begin
idPessoa := ????????;
End
Else if SourceDS = qryPessoaJuridica then
Begin
DeltaDS.FieldByName('pessoa_juridica_id').NewValue := idPessoa;
End;
end;