Solved

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

Posted on 2013-01-10
2
430 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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…

832 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