Solved

Using Cached Updates

Posted on 1997-07-23
8
178 Views
Last Modified: 2010-04-04
I have a lot of Inserts to do in a Sybase table.  I want to use cached updates to lower network traffic.  I use a Tquery with the query Insert into TAble1 (Field1,field2,...) VAlues ("value1","value2",..).  I change TQuery.SQL for each insert and use Tquery.ExecSQL.  After a hundred inserts I do TDatebase.ApplyUpdates and I receive the error : Tquery isn't a TDatabase dataset.  Is there a way to do this task?
0
Comment
Question by:brutus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 1

Expert Comment

by:jackb022197
ID: 1339585
Add the DBiProcs unit to your uses clause and
put DBiSaveChanges(TableName.Handle) in your code to flush all cached changes.
Another option is adding DBiUseIdleTime to your app in the OnIdle event.

Jack

0
 

Author Comment

by:brutus
ID: 1339586
I don't think your methods are of some use for cached updates. If they do, I would need more information on that unit because there isn't info in Delphi manuals.
0
 
LVL 1

Expert Comment

by:jackb022197
ID: 1339587
These procs work for me... I used to lose a record now and then after posting it. These functions did the trick for me.
The problem is that there is very little doc's about these procs available, but this is what I have on the DBiSaveChanges proc:

Unit:    DbiProcs

Section: Data Access: Logical Record Level

Description:   Flush all buffered changes

Parameters:    hCursor : hDBICur   Cursor handle

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:brutus
ID: 1339588
When do I use these procs. After ApplyUpdates? Do I keep the Tquery and Tdatabase?  Can You show me somw code?
0
 
LVL 1

Expert Comment

by:jackb022197
ID: 1339589
I guess you should use it near the TDatabase.ApplyUpdates you mentioned in your question.
I use something like this on Paradox tables:

  with Table1 do
    begin
       Table1.Edit;
       Table1FirstField.AsString := 'ABCDE';
       Table1SecondField.AsInteger := 123;
       Table1.Post;
       DBiSaveChanges(Table1.Handle);
    end;

0
 

Author Comment

by:brutus
ID: 1339590
I specified in my question that I was working with a Sybase Server. I have to add records to the table with an SQL Insert query so I won't lock the table.  Also there is a autoincrement field in the table. I can specify a value for all the fields except this one. If I use your method, I will receive the error:Field[0] has no specified value. Also I find your method quite confusing since you don't use any of the cached updates' methods like ApplyUpdates, commit, etc.
0
 

Author Comment

by:brutus
ID: 1339591
Adjusted points to 200
0
 
LVL 1

Accepted Solution

by:
jackb022197 earned 200 total points
ID: 1339592
What happens when you call the TQuery.ApplyUpdates instead of the TDatabase.ApplyUpdates?
Sample:

  Database1.StartTransaction;
  try
    Query1.ApplyUpdates;
    Database1.Commit;
  except
    Database1.Rollback;
    raise;
  end;
  Query1.CommitUpdates;

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question