SET PATH *LIBL ; 

CREATE OR REPLACE FUNCTION CISTOOLS.QCMD ( 
	CMD VARCHAR(32000) ) 
	RETURNS CLOB(2147483647)   
	LANGUAGE SQL 
	SPECIFIC CISTOOLS.QCMD 
	NOT DETERMINISTIC 
	MODIFIES SQL DATA 
	CALLED ON NULL INPUT 
	NOT FENCED 
	SET OPTION  ALWBLK = *ALLREAD , 
	ALWCPYDTA = *OPTIMIZE , 
	COMMIT = *CHG , 
	DECRESULT = (31, 31, 00) , 
	DFTRDBCOL = QSYS2 , 
	DLYPRP = *NO , 
	DYNDFTCOL = *NO , 
	DYNUSRPRF = *OWNER , 
	SRTSEQ = *HEX , 
	BINDOPT = 'BNDDIR(QC2LE)'   
	BEGIN 
MAIN : BEGIN 
DECLARE RC VARCHAR ( 256 ) DEFAULT '' ; 
DECLARE LOCAL_ERRNO INT DEFAULT 0 ; 
DECLARE RTNOUT CLOB ( 2 G ) DEFAULT '' ; 
DECLARE ERR INT DEFAULT 0 ; 
IF CMD IS NULL THEN 
SET CMD = '' ; 
END IF ; 
INCLUDE CISTOOLS / QSRCF ( QCMD ) ; 
SET RTNOUT = GET_CLOB_FROM_FILE ( RC ) ; 
SET ERR = SYSTOOLS . IFS_UNLINK ( RC ) ; 
RETURN RTNOUT ; 
END ; 
END  ; 

GRANT ALTER , EXECUTE   
ON SPECIFIC FUNCTION CISTOOLS.QCMD 
TO AMAPICS WITH GRANT OPTION ; 

GRANT EXECUTE   
ON SPECIFIC FUNCTION CISTOOLS.QCMD 
TO PUBLIC ; 

