Solved

Queries and Cached Updates

Posted on 1997-12-11
4
135 Views
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
try
   Query1.Open;
   While not Query1.eof do
      begin
           PrintRoutine(Query1);
           Query1.Edit;
           Query1.FieldByName('DATEBILLED').Value := Date;
           Query1.FieldByName('ACTCODE').Value := 3;     (***marks the row
as printed**)
           Query1.Post;
           Query1.Next
      end;
except
   showerror
end;
3. update the rows as printed
MyDatabase.ApplyUpdates([Query1]);

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

0
Comment
Question by:jeisen
  • 2
4 Comments
 
LVL 1

Expert Comment

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

Author Comment

by:jeisen
ID: 1353415
In response to the question about the UpdateSQL Property:
update CustomerTable
  ACTCODE = :ACTCODE,
  DATEBILLED = :DATEBILLED
where
  CUSTOMER = :OLD_CUSTOMER

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

Accepted Solution

by:
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.
0
 

Author Comment

by:jeisen
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
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

16 Experts available now in Live!

Get 1:1 Help Now