X10 Community Forum

🖥️ActiveHome Pro => SDK => Topic started by: dilip on April 09, 2008, 04:13:10 PM

Title: Trigger an Light Bulb or Siren based on an update on SQL database
Post by: dilip on April 09, 2008, 04:13:10 PM
Hello,
  Is there a way to trigger a light bulb based on a SQL database update. I work for a Sales company and I manage a  SQL database
to store Sales information.As soon as we sell equipment and the invoice gets inserted/updated on the database. I would like to
trigger an ActivePro object that could light up the a bulb whenever the database gets inserted/updated with a new sale. 
The reason to do this is to indicate visually/audio the sales people in the floor that a sale has been made.

Thanks
Dilip
Title: Re: Trigger an Light Bulb or Siren based on an update on SQL database
Post by: -Bill- (of wgjohns.com) on April 09, 2008, 10:11:05 PM
Hello,
  Is there a way to trigger a light bulb based on a SQL database update. I work for a Sales company and I manage a  SQL database
to store Sales information.As soon as we sell equipment and the invoice gets inserted/updated on the database. I would like to
trigger an ActivePro object that could light up the a bulb whenever the database gets inserted/updated with a new sale. 
The reason to do this is to indicate visually/audio the sales people in the floor that a sale has been made.

Thanks
Dilip

The main issue is, how to know the database has been updated with a sale.

Do you have access to the code that writes to the database?

If not, I have no idea how you would get the trigger in the first place.

Thoughts?
Title: Re: Trigger an Light Bulb or Siren based on an update on SQL database
Post by: doum on April 10, 2008, 12:04:33 PM
What type of SQL Database?

If MSSQL, you can easily write an After Update Trigger that will send the command with ahcmd or launch an EXE that you developed with the SDK.
Title: Re: Trigger an Light Bulb or Siren based on an update on SQL database
Post by: rossopoulosg on April 10, 2008, 12:05:39 PM
Hi,
From my (short) experience, AH does not allow any interaction with external events...
I was looking for the "smart" macros to allow checking of simple things like, a file being present
or containing a value... nothing! The "flags" are purely internal.

Now for the database change, I guess, depending on the DB you use,
you should be able to fire triggers that could call the buggy "ahcmd"
and switch a light / siren or anything else... but that's for the upper market DBs...
I'm not sure MySQL has triggers... SQL Server / Oracle have these features.

Otherwise, as Bill mentionned, you can use ahcmd in your code before the db update,
but that's only if you have access to the code...

Cheers
Title: Re: Trigger an Light Bulb or Siren based on an update on SQL database
Post by: EL34 on April 10, 2008, 01:00:17 PM
You don't do it from AH, you do it with the SDK and whatever language you use.
In VB you can access databases and have events triggered as doum said.