SET PATH *LIBL ; 

CREATE OR REPLACE FUNCTION CISTOOLS.GET_QUOTED ( 
	IN_STRING CLOB(1048576) ) 
	RETURNS CLOB(2097152)   
	LANGUAGE SQL 
	SPECIFIC CISTOOLS.GET_QUOTED 
	DETERMINISTIC 
	READS SQL DATA 
	RETURNS NULL ON NULL INPUT 
	SET OPTION  ALWBLK = *ALLREAD , 
	ALWCPYDTA = *OPTIMIZE , 
	COMMIT = *NONE , 
	DECRESULT = (31, 31, 00) , 
	DYNDFTCOL = *NO , 
	DYNUSRPRF = *USER , 
	SRTSEQ = *HEX   
	BEGIN 
-- Double up single quotes 
RETURN '''' || REPLACE ( IN_STRING , '''' , '''''' ) || '''' ; 
END  ; 

COMMENT ON PARAMETER SPECIFIC FUNCTION CISTOOLS.GET_QUOTED 
( IN_STRING IS 'Input String' ) ; 

LABEL ON SPECIFIC FUNCTION CISTOOLS.GET_QUOTED 
	IS 'Get Quoted' ; 

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

GRANT EXECUTE   
ON SPECIFIC FUNCTION CISTOOLS.GET_QUOTED 
TO PUBLIC ; 

