Detecting events in a MySQL database?

Hi all,

Is there a way to find out if an event of some kind has occurred to a MySQL table, such as adding a new record?

Currently, I have my program checking every few seconds (over … and over again) the table, to see if any new records have been added, but … this just seems so brute force in it’s approach.

Is there a feature that will notify an app of a change event for a table?

Thank you … and Happy New Year!! :smiley::+1:

Hi Byron,

Happy New Year! :partying_face:

You can have a look at MySQL triggers:

I’m going to guess the table is being updated from some other program/software you don’t control? If so, triggers are probably your best bet.

If the updates are happening from your software, but you just don’t know when, you might want to consider creating some sort of internal notification system so you have more control over what happens. (you can do a lot more in Xojo than you can do with MySQL Triggers)

FYI, triggers only allow you to make additional adjustments to the MySQL data; they’re not a way for your DB to communicate directly with your app, however…

If the trigger writes some sort of transaction data to a “transactions” table, then you can monitor this table, just checking for any “unprocessed transactions”. This is a much less heavy operation than checking every record in a table to see if it’s new or updated.

HTH!
Anthony

1 Like

Hi Anthony,

Thank you so much! Yes, that’s very helpful info and good to know… Yup, other 3rd-party applications will be accessing the same database, so I’m never fully sure when others will be adding to the database table. :wink:

Much appreciated – and Happy New Year! :+1: