• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Database Updation?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to know whether a data base is updated with new row?Means my program is hitting DB every 1 minute but how to check whether new row is inserted or not?
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Amruta Jegarkal wrote:How to know whether a data base is updated with new row?Means my program is hitting DB every 1 minute but how to check whether new row is inserted or not?


Hi Amruta,

By 'data base is updated with new row' I assume you mean to say 'table is updated with new row'.

In this case, there are several ways (e.g. adding timestamp etc.). I personally would prefer to use a DB sequence in that table.

So, whenever a new row is added, the sequence will be updated (it can be done via query or a trigger on insert), and the program will keep on reading only 'new rows whose sequence id is more than greatest sequence number of last time'.

I hope this helps.
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could perform a SQL count of rows on the table being updated before and after.

Also, not being rude but updation is not a word, it is simply update.
 
Marshal
Posts: 64616
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our databases fora.
 
Sheriff
Posts: 3752
62
Netbeans IDE Oracle Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Anayonkar Shivalkar wrote:In this case, there are several ways (e.g. adding timestamp etc.). I personally would prefer to use a DB sequence in that table.

So, whenever a new row is added, the sequence will be updated (it can be done via query or a trigger on insert), and the program will keep on reading only 'new rows whose sequence id is more than greatest sequence number of last time'.


This will probably work in most cases, but not necessarily in all. It is possible to miss added rows in the described setup.

I've already described the problems with finding out recently added rows several times on the Ranch, for example here. (It applies to Oracle. Other databases, which support read uncommitted isolation level, might have no problems finding all added rows, but would have problems weeding out rows that were eventually rolled back.)
 
No holds barred. And no bars holed. Except this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!