?
Solved

Using Cached Updates

Posted on 1997-07-23
8
Medium Priority
?
179 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 400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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