ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

SQL Trigger - Can it send a msg to the program that fired it?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SQL Trigger - Can it send a msg to the program that fired it?

    Hi All

    I've done a few SQL triggers, without having really become an expert - I started with a sample I found somewhere then added bits on with each new trigger I did.

    I'm about to do one now that will achieve the following:
    When a record is added from an existing interactive green-screen maintenance program (a standard 'package' program which I'm not permitted to change by the way), the trigger will check if that specific update should apply to a range of records.

    For instance, the insertion is for a key that contains a specific customer, but we want the same information to be added for all customers in the same group without the user having to do the same data entry twenty or thirty times.

    The actual trigger code is no problem - I know how to do that. My usual technique is to then send an email to the person telling them what's just happened as a result of the trigger (their email address can be inferred from their user profile name).

    What I would prefer however, is that a message display on the workstation message line, saying something like 'All customers in group ABC have been updated', with second level text explaining that if that wasn't intended they should contact IT to have it reversed. The maint. pgm is interactive - no batch option - so I know that the update/trigger will occur while the person has the screen displayed, but I'm pretty fuzzy/rusty on message processing. I seem to remember it's possible to "pass a message up" but I'm not sure how to do that.

    BTW I do my triggers as SQLRPGLE free-format programs (green-screen, PDM) with EXEC SQL statements (CREATE OR REPLACE TRIGGER ... BEGIN ... END), which I compile then run to create the SQL trigger itself. I don't program in C.

  • #2
    P.S. I probably should have said that I already know the calling program and its position in the stack, so it's only the message passing technique I need.

    Comment

    Working...
    X