Board index » delphi » Update Failed message, but update actually posted

Update Failed message, but update actually posted

Hello,

We are using MSSQL 7 with the BDE 5.01 and Delphi 4.03 C/S version for
our application.  We are using TStoredProc objects with cached updates
to do all of the database work (well... almost all of it.)  We have run
into a situation where we are posting the cached updates to the server
(via a TUpdateSQL object) and we are getting an "Update Failed" message,
but the update actually posted to the database.  The TUpdateSQL object
just runs another stored procedure to either modify, delete or add a
record.

Anyone know what causes this and how we can eliminate the message?

Thanks much,
Curt

 

Re:Update Failed message, but update actually posted


"Update failed" is raised by the VCL when the update action affects more
than one row (or no rows). Are you using TUpdateSQL with a "EXEC MyProc"
statement? Just create an event handler for OnUpdateRecord and call yourself
the procedures; don't let VCL do it for you.

Ian

Re:Update Failed message, but update actually posted


Yep, we are just executing a stored procedure in the TUpdateSQL.  Here is the
call from one of the TUpdateSQL objects to modify the data.

modElement :number,:periodic_number,:symbol,:disp_order,:priority,:description

That makes since, because in some cases the tables have triggers that update
multiple tables in different databases, so it would affect more than one record.

So, in the OnUpdateRecord I would have to get the values for all of the fields,
set the parameters in the SP for those fields, then execute it myself with
ExecProc?

Quote
Ian Mar{*word*249}s wrote:
> "Update failed" is raised by the VCL when the update action affects more
> than one row (or no rows). Are you using TUpdateSQL with a "EXEC MyProc"
> statement? Just create an event handler for OnUpdateRecord and call yourself
> the procedures; don't let VCL do it for you.

> Ian

Re:Update Failed message, but update actually posted


Quote
>So, in the OnUpdateRecord I would have to get the values for all of the
fields,
>set the parameters in the SP for those fields, then execute it myself with
>ExecProc?

Ouch! No, you have a better way:

procedure TDataModule2.Query1UpdateRecord(DataSet: TDataSet; UpdateKind:
TUpdateKind;
  var UpdateAction: TUpdateAction);
begin
  UpdateSQL1.SetParams[UpdateKind];
  UpdateSQL1.Query[UpdateKind].ExecSQL;
  UpdateAction := uaApplied;
end;

I've just copied the source code from the VCL and drop the line that tests
for RowsAffected. Hope this help.

Ian

Other Threads