[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

code in for loop

Posted on 2011-05-06
4
Medium Priority
?
513 Views
Last Modified: 2013-12-07
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;
0
Comment
Question by:thota198
  • 2
4 Comments
 
LVL 6

Expert Comment

by:theKashyap
ID: 35704461
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
 
LVL 6

Expert Comment

by:theKashyap
ID: 35704467
Also post the declaration of "type of v_email_replace_vals"
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 35705224
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
 
LVL 21

Expert Comment

by:Amitkumar P
ID: 35712088
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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question