I'm trying to update a table at runtime using a temporary Query. In the end it does not show any errors or exceptions, but when I query the table the information has not been updated. Basically I'm updating just one field, I created the connection and the query at run time, I execute the sql, and I destroy the components, but the information is not updated in the database.
procedure GravarMD5P(session_p: string; u_id: integer);
var
qryTemp: TZQuery;
conTemp: TZConnection;
begin
qryTemp := TZQuery.Create(Nil);
conTemp := CriarConexaoSec;
qryTemp.Connection := conTemp;
qryTemp.CachedUpdates := False;
ConTemp.Connect;
try
with qryTemp do
begin
SQL.Clear;
Connection.StartTransaction;
SQL.Add('update usuarios set sessao_p = :sSession_p where usuario_id = :iUsuarioID;');
ParamByName('sSession_p').AsString := 'ttaassttes';
ParamByName('iUsuarioID').AsInteger := 1;
try
ExecSQL;
ApplyUpdates;
Connection.Commit;
except
on E: Exception do
begin
ShowMessage('Erro ao gravar dados: ' + E.Message);
Connection.Rollback; // Desfaz a transação em caso de erro
end;
end;
end;
finally
conTemp.Free;
qryTemp.Free;
end;
end;
I checked if SQL.Text is correct and if it is receiving the values in the procedure parameters and they are. It simply doesn't show an error or exception, it doesn't record
. I'm using ZeosLib 8. Sorry for not including a minimal example, I'm using PostgreSQL.