• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database Updation?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our databases fora.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic