Advertisement
RibaSoft

Pegar valor antigo em um UPDATE

Jun 27th, 2023 (edited)
1,433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.54 KB | Software | 0 0
  1. try
  2.   with DataModulo.Query do
  3.   begin
  4.     if (Active) then
  5.       Close;
  6.     SQL.Clear;
  7.     SQL.Add('UPDATE PARCELAS SET VALOR = :VALOR WHERE ID = :ID RETURNING (OLD.VALOR)');
  8.     ParamByName('ID').AsInteger := AID;
  9.     ParamByName('VALOR').AsCurrency := AValor;
  10.     Open;
  11.     auxValorAntigo := FieldByName('VALOR').AsCurrency;
  12.   end;
  13.   DataModulo.Transaction.Commit;
  14. except
  15.   on E: Exception do
  16.   begin
  17.     DataModulo.Transaction.Rollback;
  18.     raise Exception.Create('Erro ao alterar o valor da parcela!' + #13 + E.Message);
  19.   end;
  20. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement