Solved

db2 trigger: call a clle from trigger insert

Posted on 2011-03-11
5
879 Views
Last Modified: 2012-05-11
Hi,
I would like to call a CLLE procedure
from a Trigger Insert.
I have a table called UPDATECMD, with a field 'OK'
when, from pc by ODBC driver, I insert a row,
I want to run a CLLE program on aS400.
How to do so?
Thanks

0
Comment
Question by:bobdylan75
  • 3
5 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 250 total points
ID: 35107857
create an external stored procedure that runs the program and use the CALL statement to call it (that how it should be done in zOS, i believe as400 should be similar)
0
 

Author Comment

by:bobdylan75
ID: 35108120
Sorry,
can you write the code of this store procedure?
thanks..
0
 

Author Comment

by:bobdylan75
ID: 35108308
sorry of the trigger..
0
 
LVL 16

Assisted Solution

by:theo kouwenhoven
theo kouwenhoven earned 250 total points
ID: 35108399
Just add the trigger like this:

ADDPFTRG FILE(UPDATECMD)  
         TRGTIME(*AFTER)  
         TRGEVENT(*INSERT)
         PGM(MYPROGRAM)  

If required you can use qualified file and program names.

If your trigger is making changes to the record. (you can by changing the buffer before insertion)
Then you have to use the same command with different parms:

ADDPFTRG FILE(UPDATECMD)  
         TRGTIME(*BEFORE)  
         TRGEVENT(*INSERT)
         PGM(MYPROGRAM)    
         ALWREPCHG(*YES)  


Beware, you have to remove the trigger before you add it again, or use CHGPFTRG otherwise you have 2 triggers on your file.

After the trigger is added, you can update the file from whatever program or even FTP, it will fire the trigger until it is removed or.... until you *Disable it with the CHGPFTRG command.


Good Luck
Murph
0
 

Author Closing Comment

by:bobdylan75
ID: 35108433
Thank you!
see you later...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now