Solved

Queries and Cached Updates

Posted on 1997-12-11
4
139 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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…

679 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