PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, October 17, 2022

[FIXED] How to detect the insertion of a new data?

 October 17, 2022     chart.js, node.js, postgresql, vue.js     No comments   

Issue

I would like to know if there is a way to detect each time there is a new data inserted in a data table so that I can update a chart in my application.

I use postgreSQL, node.js, vue.js for the framework and chart js for the display.


Solution

Assuming that the source database table contains an ID column that is incremented by a SEQUENCE, you can repeatedly select new data as follows:

SELECT * from <table name> where ID > :lastSelectedID
ORDER BY ID ASC;

In case the source table contains a column that holds the insertion date/time (i.e. CREATED), the same could look as follows:

SELECT * from <table name> where CREATED > :lastSelectedCreated
ORDER BY CREATED ASC;;


Answered By - uminder
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing