I have a table IMGMAST
, on insert, I'd like to call RPGLE program IMGCRT
to process the inserted record.
Program takes in 1 Char(12) parameter (id of the table)
Here is what I got so far:
CREATE TRIGGER PROCESS_NEW_IMG
AFTER INSERT IN IMGMAST
REFERENCING NEW AS NEW_ROW
FOR EACH ROW BEGIN ATOMIC
CALL IMGCRT(NEW_ROW.ID)
END
However I cannot create the trigger as it says it cannot find the IMGCRT
program. I tried adding library to it and still can't find it.
Do I need to wrap the call in CREATE PROCEDURE
?
Yes, you will need to define an external SQL stored procedure that points to the the RPG...
CREATE PROCEDURE IMGCRT (IN ID INTEGER)
LANGUAGE RPGLE
PARAMETER STYLE GENERAL
FENCED
MODIFIES SQL DATA
EXTERNAL IMGCRT
PROGRAM TYPE MAIN