Queries and Cached Updates

Posted on 1997-12-11
Last Modified: 2010-04-04
I run a query to select rows from a table (just one!)
based on user input. I then need to print the data from the selected rows.
The order is important, so I use an Order By clause which prevents me from
setting the RequestLive property to true. Finally, after each row is
printed, I mark the row as printed along with the date. This is important so
that if there is a printer error or other problem, the user would only need
to reprint from where they left off. The code is as follows:

1.    query the table
Select * from customertable where customernumber = :customernumb
2.    process the result
   While not Query1.eof do
           Query1.FieldByName('DATEBILLED').Value := Date;
           Query1.FieldByName('ACTCODE').Value := 3;     (***marks the row
as printed**)
3. update the rows as printed

At the MyDatabase.ApplyUpdates([Query1]) line I get an application error
with the message table is read only. I thought that is why you use a
TUpdateSQL component! I don't know if this helps you understand my problem
better or not. I have been struggling with this for awhile and would
appreciate any help. I am using Delphi 2.01 with a Paradox table.

Jay Eisenstock

Question by:jeisen
  • 2

Expert Comment

ID: 1353414
What is the contents of your UpdateSQL objects' modify property, and what are the key fields in the database?

Author Comment

ID: 1353415
In response to the question about the UpdateSQL Property:
update CustomerTable

I used the update SQL editor to generate the code. The key fields are CUSTOMER and CODENUMBER.

Accepted Solution

mvz121697 earned 200 total points
ID: 1353416
Cached update's is not supported for local table's like Paradox.
I think you should use a second query, whith an update statement for the customertable.
You can build this dynamicly with the values you read form your query1. In the where clause you use the primary key from query1. After this you have to reopen Query1 to see the results in this query.

Hope this helps.

Author Comment

ID: 1353417
I graded the answer C because I found a better solution. Here it is:
1  Change the original query to eliminate the "order by" clause and set "RequestLive" to true
2  Batch copy the query to a temporary table indexed by the values in the original "order by" clause
3  Process through the indexed table sequentially to print each value. Then, do a Locate on the query to update the values

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
automatically logging in via bde delphi 3 69
delphi parse string to params 3 99
Adoquery sql  left join does not work 25 80
PHP preg_replace code convert to Delphi 14 33
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: (…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now