• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marking data as read

 
Debbie Argulkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to read some data from a database and then mark the old data as read so that I don't read the same data over and over again, only the new data.
I am using jbdc dbc to connect to MS Access.
MS Access does not allow me to update records while I read them. Any other ideas?
Thanks,
-Deb
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Debbie
This sounds like more of an application design issue than a database retrieval issue.
If you are re-reading data from the same source to break a large amount of data into smaller manageable segments, the usual procedure is to sort the data in some-or-other order, and introduce a start-from variable (which also forms part of the sort sequence) as part of the database read criteria. The start-from variable will contain the sort value of the last row retrieved in the previous read, and used as the starting point for a subsequent read. That way you do not retrieve records that have already been read or processed.
You certainly would not want the overhead of updating records as being 'read' to save them from being re-read.
Please clarify if I have misunderstood your query
Mark.
 
Debbie Argulkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Thanks for your reply. Actually, the database is going to have records inserted on a continous basis by another program and my code has to read the new records and pass them to another program. The problem is that I should not read the old data again and again but only read the latest inserts.
Thanks in advance,
-Deb
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may then need to consider updating the records as you process them. This does not happen at the same time as your retrieval query though. As you loop through the records you've retrieved from the database (presumably with an included criterion of "where dataRead = 'N'), you need to make a database update call for each record processed, setting dataRead = 'Y'.
This is, of course, not a very elegant solution. The data representation in the database becomes dependant on the processing logic of a particular program. What if another program wants to process the same data?
You may consider adding something like timestamp attributes to your database records when they are initially created. The retrieval program could then include all programs from a point in time where it last left off, and store the new time for it's next run, and so forth.
This way the actual data is not geared for any particular program. As an aside, timestamp attributes are always useful in database records for various reasons, including data integrity checks (eg checking whether the data you read from the database has not been modified by another user between the time of your program's read and update database calls)
Hope this helps
 
Debbie Argulkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Thanks. That most certainly helps. I will try it out and let you know how it goes.
Thanks,
-Deb
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic