How to retrieve the id inserted in sqlserver database using delphi datasnap

0

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;
    
asked by anonymous 09.01.2017 / 22:27

0 answers