Board index » delphi » "Update failed" on paradox cached update

"Update failed" on paradox cached update

I am converting my application from using TTable object to TQuery and
TUpdateSQL objects.  I use the TDatabase object in a data module form.

I have several unrelated tables that I reference and update.

I did not have any problem when I converted the first table to a
query/update SQL pair.  However, with the second and third tables, I get an
"update failed" error when I run the TQuery.ApplyUpdates method.  As you can
see below, this is in a try...except construct.  However, when this fails,
it does not appear to be executing the except part of the construct.
Help!!!

I have tried having seperate routines for each query object, I have tried
embedding them in the same transaction, nothing works.  Am I limited to one
TQuery/TUpdateSQL object per TDatabase object?  This does not make sense.

Perhaps I need to do something after CommitUpdates.  However, I use this
same technique in other programs with multiple TQuery per TDatabase without
problems.

Help and guidence is greatly appreciated.

 - Rich

//************************
procedure tfrmMain.ApplyCachedUpdates(TargetQuery: TQuery);
begin
  dmMain.dbPrivate.StartTransaction;
  try
    TargetQuery.ApplyUpdates;        // Succeeds on first query, fails on
second here.
    dmMain.dbPrivate.Commit;
  except
    dmMain.dbPrivate.Rollback;
    raise;
  end;
  TargetQuery.CommitUpdates;
end;
//*************

 

Re:"Update failed" on paradox cached update


"R P Poletti" <rich_pole...@ccmail.columbia.com> wrote:

Quote
>I did not have any problem when I converted the first table to a
>query/update SQL pair.  However, with the second and third tables, I get an
>"update failed" error when I run the TQuery.ApplyUpdates method.  As you can
>see below, this is in a try...except construct.  However, when this fails,
>it does not appear to be executing the except part of the construct.
>Help!!!

Rich,

That has to be one of the most instructive error messages ever devised,
don't you agree<g>.

In TUpdateSQL, it almost always means that your SQL affected more than one
row. A peculiarity of TUpdateSQL is that each execution must handle exactly
one row. Any more or less and you get that message.

To test this out, try the SQL in paradox desktop and see the result. You
won't be constrained there, but my money is on the idea that your SQL does
not do just one row.

Phil Cain
--

Re:"Update failed" on paradox cached update


Thanks for the insight, but I do not believe that it applies in this
particular instance.  I may have updated many rows before applying the
cached update, each row updated was a discrete call to the TUpdateSQL.

I have not had a problem with TUpdateSQL when it applied to more than one
row.  In any case, that is not the problem.  The problem is more than one
TQuery/TUpdateSQL using the same TDatabase.  As long as I use only one of
the TQuery/TUpdateSQL pairs on the TDatabase, I have no problems.  It does
not matter which one.  It is when I have moer than one pair per TDatabase
that the second and subsequent update attempts fail.

 - Rich Poletti

Quote
"Philip Cain" <philc...@orelle.com> wrote in message

news:ocrc5t4enj5dm8f35gkrq4qobk6khmr735@4ax.com...
Quote
> "R P Poletti" <rich_pole...@ccmail.columbia.com> wrote:

> >I did not have any problem when I converted the first table to a
> >query/update SQL pair.  However, with the second and third tables, I get
an
> >"update failed" error when I run the TQuery.ApplyUpdates method.  As you
can
> >see below, this is in a try...except construct.  However, when this
fails,
> >it does not appear to be executing the except part of the construct.
> >Help!!!

> Rich,

> That has to be one of the most instructive error messages ever devised,
> don't you agree<g>.

> In TUpdateSQL, it almost always means that your SQL affected more than one
> row. A peculiarity of TUpdateSQL is that each execution must handle
exactly
> one row. Any more or less and you get that message.

> To test this out, try the SQL in paradox desktop and see the result. You
> won't be constrained there, but my money is on the idea that your SQL does
> not do just one row.

> Phil Cain
> --

Re:"Update failed" on paradox cached update


"R P Poletti" <rich_pole...@ccmail.columbia.com> wrote:

Quote
>I have not had a problem with TUpdateSQL when it applied to more than one
>row.  In any case, that is not the problem.  The problem is more than one
>TQuery/TUpdateSQL using the same TDatabase.  As long as I use only one of
>the TQuery/TUpdateSQL pairs on the TDatabase, I have no problems.  It does
>not matter which one.  It is when I have moer than one pair per TDatabase
>that the second and subsequent update attempts fail.

Rich,

I don't understand. I have many "pairs" working without a problem.

Are you trying to use more than one TUpdateSQL with the same TQuery?

Are you using threads so that you have nearly simultaneous TUpdateSQLs
going?

Phil Cain
--

Re:"Update failed" on paradox cached update


I figured out my problem.  The error messages was correct, just incomplete.
I had a data problem, duplicate keys.  Sorry for the false alarm.

 - Rich

Quote
"Philip Cain" <philc...@orelle.com> wrote in message

news:79gq5t8eudn65mnn88abeq7394vqcf0df9@4ax.com...
Quote
> "R P Poletti" <rich_pole...@ccmail.columbia.com> wrote:

> >I have not had a problem with TUpdateSQL when it applied to more than one
> >row.  In any case, that is not the problem.  The problem is more than one
> >TQuery/TUpdateSQL using the same TDatabase.  As long as I use only one of
> >the TQuery/TUpdateSQL pairs on the TDatabase, I have no problems.  It
does
> >not matter which one.  It is when I have moer than one pair per TDatabase
> >that the second and subsequent update attempts fail.

> Rich,

> I don't understand. I have many "pairs" working without a problem.

> Are you trying to use more than one TUpdateSQL with the same TQuery?

> Are you using threads so that you have nearly simultaneous TUpdateSQLs
> going?

> Phil Cain
> --

Other Threads