Trigger to write data to disk
Posted in 2009
Topics: Stored Procedures & SPL, Triggers, Constraints & Referential Integrity, Versions, Editions & End-of-Life
Hi, I'm looking for some help in this: My setup: IDS 10.00UC6 CentOS 5.2 i386 I was asked to help create a trigger that saves the content of a record to a plain text file on every update and delete of the row, so my question is: Is there any function standard to Informix that I can use to acomplish this? If there is none, have any of you a function, SPL or datablade to acomplish this?? Thanks in advance! Javier Hernández Consultor Soluciones Integrales AMR, S.A. de C.V.
My <insert appropriate deity> man, what ever the HECK for? Can't be done in SPL at all except by RUNning an external program that is either passed the record on its command line or is passed the key to the row and connects to the engine to get the data itself. Very slow and inefficient. To do this with any kind of efficiency, you will have to write a 'C' function to open the file if it's not already open, write a record to the file and flush it. Then you will have to link the function into a shared library and register the function and its library as a UDR (User Defined Routine). Once that is done, you will be able to call that function from your trigger to output the record with at least a little efficiency. Another possibility would be to install the MQ datablade and MQ support in your OS. Then you can create an MQ pseudo-table and have the trigger copy the row to the MQ table which will automatically post it to the associated MQ. You can then have an MQ client listening on the MQ for new data and that task would write the records to the disk file. Art Art S. Kagel Oninit (www.oninit.com) IIUG Board of Directors (art@iiug.org) Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Oninit, the IIUG, nor any other organization with which I am associated either explicitly or implicitly. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. 2009/10/20 JAVIER HERNáNDEZ <javier_hdzt@yahoo.com.mx> > Hi, > > I'm looking for some help in this: > > My setup: > IDS 10.00UC6 > CentOS 5.2 i386 > > I was asked to help create a trigger that saves the content of a record to > a > plain text file on every update and delete of the row, so my question is: > > Is there any function standard to Informix that I can use to acomplish > this? > If there is none, have any of you a function, SPL or datablade to acomplish > this?? > > Thanks in advance! > > Javier Hernández > Consultor > Soluciones Integrales AMR, S.A. de C.V. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --0015174bed9269ef3e0476662f10
What he (Art) said... much smarter move is to look into the built-in auditing OR use a trigger to dump the rows to your own auditing table. From there you can unload the rows at your leisure. Probably the person asking for this isn't comfortable with the idea of a database engine being the all-knowing bucket for your corporate data. Do you think they feel more comfortable copying some critical data to a so-called real file?
Art, I was afraid of that answer, but never the less... Thank you very much for your sugestion. I'm not a real programer so I'll try to pass the bucket...Involve some one else with the expertise required! Javier Hernández Consultor Soluciones Integrales AMR, S.A. de C.V.
I'll bring the issue with the user, Thanks all for your sugestions! Javier Hernández Consultor Solucioner Integrales AMR, S.A. de C.V.