lundi 16 mars 2015

How to truncate and add new rows to the table with a select query never getting empty results

I have a requirement where a table holds the state of certain things. This table is truncated and new status data in inserted in it every second. The problem is that if a select query is executed between a delete and the following insert, the user will get empty table in return. SQL Transactions would not help here i think but not sure. Also, if the select query is executed between the delete and insert query, it shouldn't return error because its blocked by a database lock. it should just wait till the delete + insert operation is finished.


What would be the best way to implement such a system? How should i form the "delete + insert" query and the "select" query?


Thank you in advance.


Aucun commentaire:

Enregistrer un commentaire