I am somewhat new to PL/SQL, and am having a little trouble using a cursor that I created. I am writing a procedure that sends emails to particular people. Here is the relevant code:
sql stmt := ' -- All my sql is in here -- ';
open email_cursor for sql stmt;
fetch email_cursor into term, award, desc, id, name, xmdt;
.....
if v_id is not null then
email_adr := schema1.get_email_adr(v_id); --This is partly where problem is.
if v_opt_ltr = 'Y' then --a variable that decides if an email should be sent
UTL_MAIL.SEND (sender => email_from,
recipients => email_adr,
subject => v_email_subject,
mime_type => 'text/html',
message => email_body );
END IF;
END IF;
Okay, so I dont get any errors or anything when I run this, but for some reason when I run the function for the email_adr variable it fails, and doesnt give me anything, and in turn wont send an email.
Another question (because I am new to cursors): The v_id in the cursor should have about 25 records, if I run the line “stu_email := schema1.get_email_adr(v_id);” will this give me all 25 records, and then will the “utl_mail.send” send an email to all the recipients?
As I understand it, you cursor is inside the
get_email_adrfunction, is that right? Althought none of those variables looks obviously like an email address, so I’m a little confused.If so then it all depends on how the code inside the
get_email_adrfunction works. Every time youopena cursor it “resets” it. So if you want to combine all 25 records you’ll need to have some code for it. Something like this:Does that kind of answer you question or have I missed the point entirely?