MySQL Forums
Forum List  »  Triggers

Re: Trigger not working
Posted by: Devart Team
Date: November 28, 2011 09:51AM

I think your INSERT statement should be like this -

...
INSERT INTO db2.Hearbeat_tbl (ID,EventName,Hostname,UpdInterval,State,ExternalCmd,ThreadID)
VALUES (new.triggerid,new.description,@hostName,'10',0,'MyExternalCommand',0);
...

---------------------------------------------------------

Another way - try to use one INSERT...SELECT query to fill the Heartbeat_tbl table.

This SELECT query should return the 'host' you need:
SELECT h.host FROM functions f
  JOIN items i
    ON i.itemid = f.itemid
  JOIN hosts h
    ON h.hostid = i.hostid
WHERE f.triggerid = NEW.triggerid;

Insert query:

INSERT INTO db2.Hearbeat_tbl (ID, EventName, Hostname, UpdInterval, State, ExternalCmd, ThreadID)
SELECT
  NEW.triggerid,
  NEW.description,
  h.host,
  '10',
  0,
  'MyExternalCommand',
  0
FROM functions f
  JOIN items i
    ON i.itemid = f.itemid
  JOIN hosts h
    ON h.hostid = i.hostid
WHERE f.triggerid = NEW.triggerid;

Devart Company,
MySQL management tools
http://www.devart.com/dbforge/mysql/

Options: ReplyQuote


Subject
Views
Written By
Posted
3012
November 28, 2011 04:46AM
Re: Trigger not working
1127
November 28, 2011 09:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.