Hi,

Since, it is an endless loop you are getting the error. To come out of the loop, include the below command in your code before the END LOOP;

EXIT WHEN C@%NOTFOUND;

Your code should be,

ELSE
Comp_list := Comp_list || CompId || ',' ;
END IF;

n := n+1;

EXIT WHEN C2%NOTFOUND; --- Added by me

END LOOP;


Hoep this will help you.