code in for loop

i would like to know whts happening in the below loop
FOR l_cnt IN v_email_replace_vals.FIRST .. v_email_replace_vals.LAST
           LOOP
                o_email_subject := REPLACE (o_email_subject, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
                o_email_to := REPLACE (o_email_to, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
                o_email_cc := REPLACE (o_email_cc, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
                v_email_replace_vals (l_cnt).fieldvalue := REPLACE ((REPLACE ( v_email_replace_vals (l_cnt).fieldvalue, '<to>', v_message_to)),
                                                 '<cc>',
                                                 v_message_cc
                                                );
               
               o_email_text := clobreplace_fn (o_email_text,
                                               v_email_replace_vals (l_cnt).fieldname,
                                               NVL (v_email_replace_vals (l_cnt).fieldvalue, ' ')
                                              );
           
           END LOOP;
thota198Asked:
Who is Participating?
 
sdstuberCommented:
loop through array

REPLACE(a,b,c)


for each A,  look for B,  replace it with C


looks like it's similar to the array based replacements I suggested in a previous question you asked
0
 
theKashyapCommented:
It would be easier if you could post declarations of v_* and o_* variables and the REPLACE function.
I've tried to put comments inline below:
-- loop over list of objects with l_cnt as index.
           FOR l_cnt IN v_email_replace_vals.FIRST .. v_email_replace_vals.LAST
           LOOP
-- replace the old subject (o_..) with the new subject v_email_replace_vals (l_cnt).fieldvalue)
                o_email_subject := REPLACE (o_email_subject, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
-- similarly replace to & cc using REPLACE function
                o_email_to := REPLACE (o_email_to, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
                o_email_cc := REPLACE (o_email_cc, v_email_replace_vals (l_cnt).fieldname, v_email_replace_vals (l_cnt).fieldvalue);
                v_email_replace_vals (l_cnt).fieldvalue := REPLACE ((REPLACE ( v_email_replace_vals (l_cnt).fieldvalue, '<to>', v_message_to)),
                                                 '<cc>',
                                                 v_message_cc
                                                );
-- e-mail text is stored CLOB so the REPLACE function has a special overload. Does the same thing, replace old with new.               
               o_email_text := clobreplace_fn (o_email_text,
                                               v_email_replace_vals (l_cnt).fieldname,
                                               NVL (v_email_replace_vals (l_cnt).fieldvalue, ' ')
                                              );
           
           END LOOP;

Open in new window

0
 
theKashyapCommented:
Also post the declaration of "type of v_email_replace_vals"
0
 
Amitkumar PSr. ConsultantCommented:
thota198,

It seems the fork generates an actual email contents based on the provided values and the email template. It replaces the placeholder by the provided values. However, I appreciate if you post the entire code.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.