This loop really looks strange. What are you trying to do there? More often than not, a "LOOP" approach is the worst solution you can use. Also: the SELECT p1_per_rot into nbmois FROM opt_par is dangerous as you are not using an WHERE clause to limit the number or rows from opt_par
SELECT p1_per_rot into nbmois FROM opt_paris dangerous as you are not using an WHERE clause to limit the number or rows fromopt_par