trigger depending on user
Posted in 2013
Topics: Triggers, Constraints & Referential Integrity
Hi all, I would like to buiid a trigger which executes a procedure, which one of the parameter is the user who causing the launch of the trigger. How can I do this? Thanks a lot, Rafael
Just pass in the defined global variable USER to the procedure: create trigger .... ON EVERY ROW execute procedure my_trig_prog( USER, ... ) ...; Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Wed, May 29, 2013 at 5:32 AM, RAFAEL SEGOVIA <rafael.segovia@fi2net.es>wrote: > Hi all, > > I would like to buiid a trigger which executes a procedure, which one of > the > parameter is the user who causing the launch of the trigger. How can I do > this? > > Thanks a lot, > > Rafael > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --089e0158ad54bfd94204ddd94eec
Triggers can test conditions... just check USER... You shouldn't need to pass it to the procedure as you can avoid calling the proc. If you prefer calling it anyway, USER is known anywhere. It doesn't need to be a parameter. Please check the CREATE TRIGGER syntax... On May 29, 2013 12:02 PM, "Art Kagel" <art.kagel@gmail.com> wrote: > Just pass in the defined global variable USER to the procedure: > > create trigger .... ON EVERY ROW execute procedure my_trig_prog( USER, ... > ) ...; > > Art > > Art S. Kagel > Advanced DataTools (www.advancedatatools.com) > Blog: http://informix-myview.blogspot.com/ > > Disclaimer: Please keep in mind that my own opinions are my own opinions > and do not reflect on my employer, Advanced DataTools, the IIUG, nor any > other organization with which I am associated either explicitly, > implicitly, or by inference. Neither do those opinions reflect those of > other individuals affiliated with any entity with which I am affiliated nor > those of the entities themselves. > > On Wed, May 29, 2013 at 5:32 AM, RAFAEL SEGOVIA > <rafael.segovia@fi2net.es>wrote: > > > Hi all, > > > > I would like to buiid a trigger which executes a procedure, which one of > > the > > parameter is the user who causing the launch of the trigger. How can I do > > this? > > > > Thanks a lot, > > > > Rafael > > > > > > > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > --089e0158ad54bfd94204ddd94eec > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --bcaec548a4939c9e2f04ddda9609
Truth. Just answering the question as given, but Fernando is absolutely right, you can just access USER inside the procedure itself without passing it in. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Wed, May 29, 2013 at 8:33 AM, Fernando Nunes <domusonline@gmail.com>wrote: > Triggers can test conditions... just check USER... You shouldn't need to > pass it to the procedure as you can avoid calling the proc. If you prefer > calling it anyway, USER is known anywhere. It doesn't need to be a > parameter. Please check the CREATE TRIGGER syntax... > On May 29, 2013 12:02 PM, "Art Kagel" <art.kagel@gmail.com> wrote: > > > Just pass in the defined global variable USER to the procedure: > > > > create trigger .... ON EVERY ROW execute procedure my_trig_prog( USER, > ... > > ) ...; > > > > Art > > > > Art S. Kagel > > Advanced DataTools (www.advancedatatools.com) > > Blog: http://informix-myview.blogspot.com/ > > > > Disclaimer: Please keep in mind that my own opinions are my own opinions > > and do not reflect on my employer, Advanced DataTools, the IIUG, nor any > > other organization with which I am associated either explicitly, > > implicitly, or by inference. Neither do those opinions reflect those of > > other individuals affiliated with any entity with which I am affiliated > nor > > those of the entities themselves. > > > > On Wed, May 29, 2013 at 5:32 AM, RAFAEL SEGOVIA > > <rafael.segovia@fi2net.es>wrote: > > > > > Hi all, > > > > > > I would like to buiid a trigger which executes a procedure, which one > of > > > the > > > parameter is the user who causing the launch of the trigger. How can I > do > > > this? > > > > > > Thanks a lot, > > > > > > Rafael > > > > > > > > > > > > > > > > > > ******************************************************************************* > > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > > > > > --089e0158ad54bfd94204ddd94eec > > > > > > > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > --bcaec548a4939c9e2f04ddda9609 > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001a11c33ffcb2baf404dddac289