"Update Failed" With Cache Update 
Author Message
 "Update Failed" With Cache Update


Quote:
> I'm changing a program to use Cache Update facilities

> I have a Read Only SQL Component linked to UpdateSQL.
> I can insert records and works fine.

> But I can't update or delete records because I get an Error "Update
> Failed"

> If I run the my program in the delphi IDE a get the same error and
> after a
> EAbort exception.

> Actually I have no code in OnUpdateError or OnUpdateRecord events.
> If I put a line of code like:
>    UpdateAction= uaApplied
>  in the OnUpdateRecord event, I don't get the error message "Update
> Failed", but the
> the records modified don't change in the database

> Actually I use the Database's ApplyUpdate method.

> Somebody help me.

> Thanks

Welcome to the problem! I have broken my head against this for three
days and finally figured out the reason. But, I don't have a good
solution yet, just workarounds!

For the TUpdateSQL to work with the modified values, you probably have
something like Query.Edit, then set your new values and do Query.Post.
This posts to the cache, but not to the database.  Then when you call
ApplyUpdates it gives the "Update Failed" error.

Seems like the reason is that there is a mix of BDE functions
(Query.Edit and Query.Post) along with an explicit SQL transaction,
because the ApplyUpdates method opens a transaction. The easiest
solution would be to have RequestLive as True (if you can) and set
Cached Updates to False and let BDE take care of the posting.

But, if your SQL statement will not return a live result set, then don't
use TUpdateSQL. Instead, use another seperate query for modifying the
record and painfully set each parameter manually and then call
NewQuery.ExecSQL within a transaction. This works, but it kills the
advantage of UpdateSQL which is setting the value of the fields
implicitly.

If anybody can help on how to set the values for TUpdateSQL without
calling Edit, it will be a great help. Borland???????????

Gowri Subramanian
Aspire Systems, Inc.
http://www.*-*-*.com/
CONSULTANTS FOR:  VB, PowerBuilder, Delphi, Oracle, Informix, Java,
Intranet and Client/Server



Mon, 01 Nov 1999 03:00:00 GMT  
 "Update Failed" With Cache Update

Quote:
>If anybody can help on how to set the values for TUpdateSQL without
>calling Edit, it will be a great help. Borland???????????

If you're using a TUpdateSQL object within, say, an OnUpdateRecord, the
way to get those Params set is this way, which D3 has in its help for
SetParams:

    with DataSet.UpdateObject as TUpdateSQL do
    begin
      SetParams(UpdateKind);
      if UpdateKind = ukModified then
        Query[UpdateKind].ParamByName('DateChanged').Value := Now;
      ExecSQL(UpdateKind);
    end;
    UpdateAction := uaApplied;

Works pretty well for me, but then again, I haven't tried transactions
yet :)

  --=- Ritchie Annand



Sun, 07 Nov 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. "update failed"

2. Cached Updates QUESTION: Sorting table of updated and non-updated records

3. Cached updates: how to retain insert mode when post fails

4. The keys "-"/"+"/"*"

5. EDBEngineError "Record lock failed message"

6. Problem with "Vendor initialisation failed" message

7. "Vendor initialization failed..."

8. Insert : OK. Modify and delete : "Update Failed"

9. ""256 Color Mouse""

10. Follow-up: the "cached-update that didn't" was, indeed, a gobbled exception

11. Error "Operation Not Applicable" While Using Cached Updates

12. each time I do an update / insert an Error is risen: "Operation on

 

 
Powered by phpBB® Forum Software