Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013
    Posts
    3

    Unanswered: Excute Perl Script

    Hi,

    I have a trigger that executes a Store Procedure. From Stored Procedure I would like to start running a perl script. How can I do?

  2. #2
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    in therory, you can do the following in the stored procedure

    Code:
    LET cmd = "/usr/bin/perl fullpaththnameofperlscript.pl arguments" ;
    SYSTEM cmd ;
    I would suggest to be cautious on carefully handling eventual exceptions that may be returned.

    Do you also know about using the Informix Perl DBD driver, which allows you to use SQL statements in your perl scripts?

    Check here for an introduction

  3. #3
    Join Date
    Feb 2009
    Location
    Brooklyn, NY
    Posts
    9
    begooden,
    While your advice about possible exceptions is a reasonable caution, it applies to any external program that the triggered stored procedure invokes.

    But it makes no difference whether or not his Perl program accesses the database; Joaquin's question hinged on just executing it from the procedure.

    But begooen's response does raise another issue, Joaquin.

    Your Perl script (or any invoked program) is running as a whole other process and if it *does* access the database, it will be running as a separate user session.
    • It will be unable to update any row you have locked
    • It may lock rows you want to update in your main application
    • Its transactions will be separate from any transaction in your application [that invoked the trigger]. If you roll back your transaction, it will *not* roll back anything done by your script.

    At a seminar about 3 years ago, I recall (not to clearly) that they discussed data-blades whose functions could be written in compiled C, SPL, or Java. I think they also mentioned Perl in the list. But I don't believe that will help with your issue of trigger-invoked scripts.

    Good luck to you!

    Rasputin (the oh, so concise) Paskudniak (In pursuit of undomesticated, semi-aquatic avians)

  4. #4
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    Totally agree Rasputin. Avoid database access in the Perl script because it will be a totally different session, then considered as a totally different user.

    UDRs can be written only in C, SPL and JAva. Perl is not in the list.

    When developping a C based UDR, you will have to indicate whether the function can be multi-threaded or not and whether parameters can change structure or not. These questions are typically in the same range as the one induced by invoking an external script accessing the database.

    If interested in developping your own Informix UDRs based on C, check this bootstrap article

  5. #5
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    381
    Provided Answers: 1
    Totally agree Rasputin. Avoid database access in the Perl script because it will be a totally different session, then considered as a totally different user.

    UDRs can be written only in C, SPL and JAva. Perl is not in the list.

    When developping a C based UDR, you will have to indicate whether the function can be multi-threaded or not and whether parameters can change structure or not. These questions are typically in the same range as the one induced by invoking an external script accessing the database.

    If interested in developping your own Informix UDRs based on C, check this bootstrap article

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •