Re: Triggers
Posted in 1995
Stuart Scott (em89@cityscape.co.uk) wrote:
: Can anyone give me a brief description of how to set up a trigger.
: The task is to trigger a UNIX mail message when a record is inserted
: into a particular table.
: I'm sure its dead easy but I don't have access to the relevant
: documentation at present.
: Version will be V5.something
It would go something like:
CREATE TRIGGER i_table INSERT ON tableREFERENCING NEW AS n_table
FOR EACH ROW
(EXECUTE PROCEDURE mail_spl("table",n_table.pk));
Then have a stored procedure:
CREATE PROCEDURE mail_spl(table_name CHAR(18),
table_pk CHAR(18)
DEFINE msg_txt CHAR(200);
LET msg_txt = "echo \\"Table " || trim(table_name) ||
" PK " || trim(table_pk) || " inserted by " ||
trim(USER) || " at " || CURRENT || "\\" | mail informix &";
SYSTEM msg_txt;
END PROCEDURE;
This is untested and bare-bones code. See Informix Guide to SQL:
Tutorial chapter 12.
=======================================================================
Dennis J. Pimple dennisp@informix.com Opinions expressed
Principal Consultant -------------------- are mine, and do not
Informix Software Inc Voice: 303-850-0210 necessarily reflect
Denver Colorado USA Fax: 303-779-4025 those of my employer.