Solved

timestamp before select after an application has successfully done stuff with a select

Posted on 2013-01-10
2
409 Views
Last Modified: 2013-01-12
I have a python script which is querying an sql-database. it does some stuff with the query, then puts a timestamp on the sql-database, so it only has to query the stuff that's happened after that timestamp.

The process takes a few minutes, so putting the timestamp at the end of the process means it might miss stuff that happened after the select query, but before it'd finished doing stuff.

I tried beginning a transaction, making a timestamp, doing the query, then committing the transaction, but it wouldn't give me the results of the select query until after i'd committed (defeating the whole point).

What is a good way of doing this?
0
Comment
Question by:rdun25
2 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 100 total points
ID: 38765698
If you can modify the table you are working with, you need to create a column called "Working", or similar. Then at the beginning of the process update the column for all unprocessed records to TRUE. Then select all records with Working=TRUE. After you process each records update the timestamp and Working=FALSE using a single UPDATE.

If you do not have access to the database, then first update the timestamp to a certain value (say your DOB), then select all records with this value. While processing each record update the record with the current time. This second method is less preferable, as it may break some reports that use this timestamp value for reporting
0
 

Author Closing Comment

by:rdun25
ID: 38770710
Thank you so much. This is going to work way better then my plan. You've prevented another problem which would have come up later as well.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

11 Experts available now in Live!

Get 1:1 Help Now