SET TERM ^ ;

create or alter procedure MGRECM_INSER_DOCTOS (
    FECHA_INI date,
    FECHA_FIN date)
returns (
    V_DOCTO_CM integer)
as
begin
    FOR SELECT DOCTO_CM_ID
    FROM DOCTOS_CM
    WHERE TIPO_DOCTO = 'R' AND (FECHA BETWEEN :FECHA_INI AND :FECHA_FIN)
    INTO V_DOCTO_CM
    DO
    BEGIN
        INSERT INTO MGRECM_DOCTOS (DOCTO_ID) VALUES (:V_DOCTO_CM);

        suspend;
    END
end^

SET TERM ; ^

/* Following GRANT statements are generated automatically */

GRANT SELECT ON DOCTOS_CM TO PROCEDURE MGRECM_INSER_DOCTOS;
GRANT INSERT ON MGRECM_DOCTOS TO PROCEDURE MGRECM_INSER_DOCTOS;

/* Existing privileges on this procedure */

GRANT EXECUTE ON PROCEDURE MGRECM_INSER_DOCTOS TO SYSDBA;