CREATE
	PROCEDURE CREDITP 
	(
		IN i_perinc DECIMAL(3,2),
		OUT o_numrec DECIMAL(5,0)
	)
	 LANGUAGE SQL 
BEGIN
	ATOMIC  
    DECLARE proc_cusnbr CHAR(5); 
    DECLARE proc_cuscrd DECIMAL(11,2);
    DECLARE numrec DECIMAL(5,0); 
    DECLARE at_end INT DEFAULT 0; 
    DECLARE not_found CONDITION FOR '02000'; 
	DECLARE c1 CURSOR FOR 
            SELECT
                cusnbr,
                cuscrd 
            FROM
                QTCP.QATMAD0001; 
DECLARE CONTINUE HANDLER FOR not_found 
    SET
	at_end = 1; 
    SET
	numrec = 0; 
        OPEN c1; 
        FETCH c1 
INTO
	proc_cusnbr,
	proc_cuscrd; WHILE at_end = 0 DO 
    SET
	proc_cuscrd = proc_cuscrd +(proc_cuscrd * i_perinc); 
        UPDATE
        ordapplib.customer 
    SET
	cuscrd = proc_cuscrd 
        WHERE
                CURRENT OF c1; 
        SET
            numrec = numrec + 1; FETCH c1 
        INTO
            proc_cusnbr,
            proc_cuscrd; 
        END
        WHILE; 
        SET
            o_numrec = numrec; CLOSE c1; 
END