Help needed Please,

I am getting error message [IBM][CLI Driver][DB2/NT] SQL0797N The trigger "DEMO.TR_INSERT_VALIDREC" is defined with an unsupported triggered SQL statement. LINE NUMBER=1. SQLSTATE=42987 when i create the following Trigger.

As per DB2 trigger rule for an After Trigger
Only Insert statment, Searched Update, Searched Delete and SET is valid. My trigger consists of some system defined functions (i.e, Substr, locate...) , IF.. Else...End if statment, While loops

Whether this too is not accepted in DB2 triggers!!!!!!.

Otherwise what would be the reason for my problem...

The trigger written by me is as follows,

Create Trigger Demo.TR_INSERT_VALIDREC After Insert ON Demo.IP_ENTRY REFERENCING NEW as NEWENT
For Each Row MODE DB2SQL
BEGIN ATOMIC
DECLARE nRQIDEN INTEGER; DECLARE sRQSTAT VARCHAR(45);DECLARE sRQTYPE VARCHAR(10);DECLARE sRQTXT1 VARCHAR(10);
DECLARE sRQTXT2 VARCHAR(30);DECLARE sRQRCBY VARCHAR(111);DECLARE sRQMODE VARCHAR(1);DECLARE nCount INTEGER;
DECLARE sName VARCHAR(10);DECLARE sName2 VARCHAR(10);DECLARE repQuer VARCHAR(255);DECLARE repOrdr VARCHAR(255);
DECLARE sValue VARCHAR(255);DECLARE sNameLst varchar(122);DECLARE lStPos INTEGER;DECLARE lEnPos INTEGER;
DECLARE nCount1 INTEGER; DECLARE nUsrCnt1 INTEGER; DECLARE nUsrCnt2 INTEGER;

SET nCount1 = (select Count(*) from IP_REQUEST where UPPER(RTRIM(RQ_EVNT)) = UPPER(RTRIM(NEWENT.RQ_EVNT)) and UPPER(RTRIM(RQ_CRIT)) = UPPER(RTRIM(NEWENT.EN_VAL1)) and RQ_STAT = 'P');

If nCount1 > 0 then
set nRQIDEN = ( Select RQ_IDEN from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and
upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQSTAT = ( Select RQ_STAT from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and
upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQTYPE = ( Select RQ_TYPE from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and
upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQTXT1 = ( Select RQ_TXT1 INTO from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQTXT2 = ( Select RQ_TXT2 from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and
upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQRCBY = ( Select RQ_RCBY from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

set sRQMODE = ( Select RQ_MODE from IP_REQUEST where upper(RTRIM(RQ_EVNT)) =Upper(RTRIM(NEWENT.RQ_EVNT)) and upper(RTRIM(RQ_CRIT)) = upper(RTRIM(NEWENT.EN_VAL1)));

SET NEWENT.EN_STAT = '1' ;

If sRQSTAT = 'P' then
SET SVALUE = CONCAT(CONCAT(CONCAT(CONCAT(NEWENT.EN_VAL1, ','),NEWENT.EN_VAL2), ','),NEWENT.EN_VAL3);
If SRQMODE = 'E' or sRQMODE ='R' then
SET sNameLst = ',MAIL_USER,';
Else
SET nUsrCnt1 = (Select count(*) from IP_ACCRIGHT where PE_LOGN = substr(NEWENT.EN_VAL2,1,10));
SET nUsrCnt2 = (Select Count(*) from IP_ACCRIGHT where PE_LOGN = NEWENT.EN_VAL1);
If nUsrCnt1 > 0 then
SET sNameLst = concat(lTrim(rTrim(sRQRCBY)), concat(rtrim(NEWENT.EN_VAL2),','));
Else
SET sNameLst = lTrim(rTrim(sRQRCBY));
End if;
If nUsrCnt2 > 0 then
SET sNameLst = concat(lTrim(rTrim(sRQRCBY)),concat(rtrim(NEWENT.E N_VAL1),','));
End if;
End if;
SET lStPos = 2;
While lStPos <= length(sNameLst) DO
SET lEnPos = LOCATE(sNameLst,',',lStPos);
SET sName = substr(sNameLst,lStPos, lEnPos - (lStPos ));
SET lStPos = lEnPos + 1;
Insert into IP_REQUESTMSG (RQ_IDEN, RM_MESG, RM_STAT, RM_LOGN) Values ( nRQIDEN, sValue, 'P', sName);
END WHILE;
End if;
Else
SET NEWENT.EN_STAT = '0' ;
End if;
END

Thanks
Arun