executing a 4GL program from a trigger?
Posted in 2009
User asked whether an INSERT trigger can execute a Unix shell program or Informix 4GL program to wake up a daemon-like 4GL process waiting for table inserts. Responses suggested: (1) using a SPL trigger with SYSTEM command to call a shell script, (2) converting 4GL logic to SPL, or (3) using a C routine callable from 4GL that blocks on a file/FIFO, with the trigger writing to that file to wake the process.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Triggers, Constraints & Referential Integrity, Platform-Specific Issues, Versions, Editions & End-of-Life
Hi all, It's been quite a while since I've tried to do something like this. ... Is it possible to create an insert trigger on a table that executes a unix shell program and/or an Informix 4GL program (not SPL)? Here's my story.... I have a 4GL program that could be made to run with an infinite while loop, always staying alive, waiting for various other programs to insert processing requests into a table. This 4Gl program would "sit & spin", waiting for records to appear in the table (like a daemon)... the 4GL would then process the records I'd rather have the 4GL program wake up/run in the event that a record is inserted into the request table. How might I do this? I unsuccessfully googled... (being rusty, my google query might not have been phrased the best).... Thanks for your suggestions and guidance. Norma Jean Sebastian I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32
Norma Jean, Not sure about the external command bit, but a safe workaround would be to create an insert trigger that just updated a row in a table with to be a 1. Have the 4GL script run by CRON every x minutes and check this "runme" table - if the row is a 1, do stuff and then set it back to a 0. I know you can call external commands from SPL, but insert SPL scares me with this - locking issues and stuff... Jarrod Teale Fonterra NZ -----Original Message----- From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Norma Jean Sebastian Sent: Tuesday, 24 March 2009 3:41 p.m. To: ids@iiug.org Subject: executing a 4GL program from a trigger? [15300] Hi all, It's been quite a while since I've tried to do something like this. ... Is it possible to create an insert trigger on a table that executes a unix shell program and/or an Informix 4GL program (not SPL)? Here's my story.... I have a 4GL program that could be made to run with an infinite while loop, always staying alive, waiting for various other programs to insert processing requests into a table. This 4Gl program would "sit & spin", waiting for records to appear in the table (like a daemon)... the 4GL would then process the records I'd rather have the 4GL program wake up/run in the event that a record is inserted into the request table. How might I do this? I unsuccessfully googled... (being rusty, my google query might not have been phrased the best).... Thanks for your suggestions and guidance. Norma Jean Sebastian I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 ************************************************************************ ******* Forum Note: Use "Reply" to post a response in the discussion forum. DISCLAIMER: This email contains confidential information and may be legally privileged. If you are not the intended recipient or have received this email in error, please notify the sender immediately and destroy this email. You may not use, disclose or copy this email or its attachments in any way. Any opinions expressed in this email are those of the author and are not necessarily those of the Fonterra Co-operative Group. http://www.fonterra.com/
What does the 4gl program do ? It it something that might be migratable to a SPL itself ? Me and Art did some work a short time ago on getting 4gl code translated to SPL. If you can separate out the 4gl code - I can try running it through and see how it looks ? On Tuesday 24 March 2009 02:41:24 Norma Jean Sebastian wrote: > Hi all, > > It's been quite a while since I've tried to do something like this. ... > > Is it possible to create an insert trigger on a table that executes a > unix shell program and/or an Informix 4GL program (not SPL)? > > Here's my story.... > > I have a 4GL program that could be made to run with an infinite while > loop, always staying alive, waiting for various other programs to insert > processing requests into a table. This 4Gl program would "sit & spin", > waiting for records to appear in the table (like a daemon)... the 4GL > would then process the records > > I'd rather have the 4GL program wake up/run in the event that a record > is inserted into the request table. > > How might I do this? I unsuccessfully googled... (being rusty, my > google query might not have been phrased the best).... > > Thanks for your suggestions and guidance. > > Norma Jean Sebastian > > I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 > > > *************************************************************************** >**** Forum Note: Use "Reply" to post a response in the discussion forum. -- Mike Aubury http://www.aubit.com/ Aubit Computing Ltd is registered in England and Wales, Number: 3112827 Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
The easiest would be to have a simple SPL store procedure which executes
your 4gl program.
If you do not want to use SPL however then you can other languages to create
your 'UDR' but it hardly seams worth it.
CREATE PROCEDURE "owner".my_proc (param_from_trigger)
DEFINE param_from_trigger WHATEVER_DATATYPE;
DEFINE system_string VARCHAR(200);
LET system_string="/mypath/run_4gl.sh "||param_from_trigger||" &";
SYSTEM system_string;
END PROCEDURE;
CREATE TRIGGER trg_mytable_ins INSERT TRIGGER ON "owner".mytable
REFERENCING new AS post
FOR EACH ROW
(
EXECUTE PROCEDURE "owner".my_proc(post.field)
);
-----Original Message-----
From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of Mike
Aubury
Sent: 24 March 2009 09:30 AM
To: ids@iiug.org
Subject: Re: executing a 4GL program from a trigger? [15305]
What does the 4gl program do ?
It it something that might be migratable to a SPL itself ?
Me and Art did some work a short time ago on getting 4gl code translated to
SPL. If you can separate out the 4gl code - I can try running it through and
see how it looks ?
On Tuesday 24 March 2009 02:41:24 Norma Jean Sebastian wrote:
> Hi all,
>
> It's been quite a while since I've tried to do something like this. ...
>
> Is it possible to create an insert trigger on a table that executes a
> unix shell program and/or an Informix 4GL program (not SPL)?
>
> Here's my story....
>
> I have a 4GL program that could be made to run with an infinite while
> loop, always staying alive, waiting for various other programs to
> insert processing requests into a table. This 4Gl program would "sit &
> spin", waiting for records to appear in the table (like a daemon)...
> the 4GL would then process the records
>
> I'd rather have the 4GL program wake up/run in the event that a record
> is inserted into the request table.
>
> How might I do this? I unsuccessfully googled... (being rusty, my
> google query might not have been phrased the best)....
>
> Thanks for your suggestions and guidance.
>
> Norma Jean Sebastian
>
> I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32
>
>
>
>***********************************************************************
>****
>**** Forum Note: Use "Reply" to post a response in the discussion forum.
--
Mike Aubury
http://www.aubit.com/
Aubit Computing Ltd is registered in England and Wales, Number: 3112827
Registered Address : Clayton House,59 Piccadilly,Manchester,M1 2AQ
****************************************************************************
***
Forum Note: Use "Reply" to post a response in the discussion forum.
==================
Please read our Email Disclaimer :
http://www.thefuelgroup.com/disclaimer.html
NJ, Write a small 4GL callable 'C' routine that blocks the 4GL on a SELECT call waiting on a file or FIFO to be written to. In the trigger, depending on the version of IDS you can: - insert to a UDT (User Defined Table) that is really the file or FIFO that the 4GL is blocked on. - call a small 'C' UDR that does a write to the file or FIFO - execute a tiny 'C' program in the background (you do NOT want to run anything in foreground from a trigger) that does the write. The write will unblock the 4GL which can process any new data it finds and then loops back to the blocking function call to wait again. Best to drain both the table's new records and the file/pipe each time you awaken just in case the 4GL app somehow missing a wake up because two came in simultaneously. Worst case it will awaken occassionally, find nothing to do, and go back to the blocked state. 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. On Mon, Mar 23, 2009 at 10:41 PM, Norma Jean Sebastian < nsebastian@flinnsci.com> wrote: > Hi all, > > It's been quite a while since I've tried to do something like this. ... > > Is it possible to create an insert trigger on a table that executes a > unix shell program and/or an Informix 4GL program (not SPL)? > > Here's my story.... > > I have a 4GL program that could be made to run with an infinite while > loop, always staying alive, waiting for various other programs to insert > processing requests into a table. This 4Gl program would "sit & spin", > waiting for records to appear in the table (like a daemon)... the 4GL > would then process the records > > I'd rather have the 4GL program wake up/run in the event that a record > is inserted into the request table. > > How might I do this? I unsuccessfully googled... (being rusty, my > google query might not have been phrased the best).... > > Thanks for your suggestions and guidance. > > Norma Jean Sebastian > > I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001636426d0d3dfbb80465db1d69
You appear to have something that works so why do you want to fix it ? If youi trigger this and you have a batch of inserts then I can see all sorts of locking/timing/conflict problems Cheers Paul ------Original Message------ From: Norma Jean Sebastian Sender: ids-bounces@iiug.org To: ids@iiug.org ReplyTo: ids@iiug.org Sent: Mar 23, 2009 21:41 Subject: executing a 4GL program from a trigger? [15300] Hi all, It's been quite a while since I've tried to do something like this. ... Is it possible to create an insert trigger on a table that executes a unix shell program and/or an Informix 4GL program (not SPL)? Here's my story.... I have a 4GL program that could be made to run with an infinite while loop, always staying alive, waiting for various other programs to insert processing requests into a table. This 4Gl program would "sit & spin", waiting for records to appear in the table (like a daemon)... the 4GL would then process the records I'd rather have the 4GL program wake up/run in the event that a record is inserted into the request table. How might I do this? I unsuccessfully googled... (being rusty, my google query might not have been phrased the best).... Thanks for your suggestions and guidance. Norma Jean Sebastian I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum. Paul Watson Tel: +1 913-400-2620 Mob: +1 913-387-7529 Web: www.oninit.com Failure is not as frightening as regret. If you want to improve, be content to be thought foolish and stupid. It is better to be criticized by a wise person than to be praised by a fool.
Looks like whatever Denny's got is catching! ;-) 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. On Tue, Mar 24, 2009 at 9:04 AM, Paul Watson <paul@oninit.com> wrote: > > You appear to have something that works so why do you want to fix it ? > > If youi trigger this and you have a batch of inserts then I can see all sorts of locking/timing/conflict problems > > Cheers > Paul > > ------Original Message------ > From: Norma Jean Sebastian > Sender: ids-bounces@iiug.org > To: ids@iiug.org > ReplyTo: ids@iiug.org > Sent: Mar 23, 2009 21:41 > Subject: executing a 4GL program from a trigger? [15300] > > Hi all, > > It's been quite a while since I've tried to do something like this. ... > > Is it possible to create an insert trigger on a table that executes a > unix shell program and/or an Informix 4GL program (not SPL)? > > Here's my story.... > > I have a 4GL program that could be made to run with an infinite while > loop, always staying alive, waiting for various other programs to insert > processing requests into a table. This 4Gl program would "sit & spin", > waiting for records to appear in the table (like a daemon)... the 4GL > would then process the records > > I'd rather have the 4GL program wake up/run in the event that a record > is inserted into the request table. > > How might I do this? I unsuccessfully googled... (being rusty, my > google query might not have been phrased the best).... > > Thanks for your suggestions and guidance. > > Norma Jean Sebastian > > I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > > Paul Watson > Tel: +1 913-400-2620 > Mob: +1 913-387-7529 > Web: www.oninit.com > > Failure is not as frightening as regret. > If you want to improve, be content to be thought foolish and stupid. > It is better to be criticized by a wise person than to be praised by a fool. > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --00163646d8bc84b1f60465dd2c7e
Only happens from my Blackberry and only to the IIUG forumsJ Only get IDS forums sporadically, its like my account is randomly disabled from days at a time Paul Watson Tel: +1 913-745-5635 Mob: +1 913-387-7529 Web: <http://www.oninit.com> www.oninit.com Failure is not as frightening as regret. If you want to improve, be content to be thought foolish and stupid. It is better to be criticized by a wise person than to be praised by a fool. From: Art Kagel [mailto:art.kagel@gmail.com] Sent: Tuesday, March 24, 2009 8:15 AM To: ids@iiug.org; Paul Watson Subject: Re: executing a 4GL program from a trigger? [15315] Looks like whatever Denny's got is catching! ;-) 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. On Tue, Mar 24, 2009 at 9:04 AM, Paul Watson <paul@oninit.com> wrote: You appear to have something that works so why do you want to fix it ? If youi trigger this and you have a batch of inserts then I can see all sorts of locking/timing/conflict problems Cheers Paul ------Original Message------ From: Norma Jean Sebastian Sender: ids-bounces@iiug.org To: ids@iiug.org ReplyTo: ids@iiug.org Sent: Mar 23, 2009 21:41 Subject: executing a 4GL program from a trigger? [15300] Hi all, It's been quite a while since I've tried to do something like this. ... Is it possible to create an insert trigger on a table that executes a unix shell program and/or an Informix 4GL program (not SPL)? Here's my story.... I have a 4GL program that could be made to run with an infinite while loop, always staying alive, waiting for various other programs to insert processing requests into a table. This 4Gl program would "sit & spin", waiting for records to appear in the table (like a daemon)... the 4GL would then process the records I'd rather have the 4GL program wake up/run in the event that a record is inserted into the request table. How might I do this? I unsuccessfully googled... (being rusty, my google query might not have been phrased the best).... Thanks for your suggestions and guidance. Norma Jean Sebastian I'm on HP-UX, IDS 10.00.FC6, 4GL 7.32 ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum. Paul Watson Tel: +1 913-400-2620 Mob: +1 913-387-7529 Web: www.oninit.com Failure is not as frightening as regret. If you want to improve, be content to be thought foolish and stupid. It is better to be criticized by a wise person than to be praised by a fool. **************************************************************************** *** Forum Note: Use "Reply" to post a response in the discussion forum.