Solved

Using Cached Updates

Posted on 1997-07-23
8
177 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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