MySQL Forums
Forum List  »  Perl

Re: Stored Procedure Calling a Perl program
Posted by: Bill Karwin
Date: June 08, 2006 11:18AM

Hmm. After a few google searches, I am not finding anything.
I'm willing to offer pseudo-code, but not a full implementation.

1. Write a trigger, spawned by the operation after which you want to create your XML.

2. Create a simple table to hold a flag value.
CREATE TABLE flag (flag_value TINYINT NOT NULL);

3. In the trigger, INSERT a value 1 to the flag table.

4. Write a Perl script that has a loop:
- Sleep for 60 seconds (or whatever length you think is appropriate)
- SELECT * FROM flag WHERE flag_value = 1
- If the result set has at least one row, it's time to create your XML.
First, UPDATE flag SET flag_value = 0. Then, proceed to create the XML.
- Return to the top of the loop.

Be sure to do the SELECT and UPDATE on the flag table in one transaction, so you don't accidentally clear any additional flags rows that have been set in the moment in between.

You can make variations. You can make the flag table contain additional information, or a timestamp, etc. You can DELETE instead of UPDATE to clear the flag table.

Regards,
Bill K.

Options: ReplyQuote


Subject
Written By
Posted
Re: Stored Procedure Calling a Perl program
June 08, 2006 11:18AM


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.