Error while passing email inside utl_mail.send (Oracle 11g - sql) 06502 - 06512

拥有回忆 提交于 2020-01-16 19:36:26

问题


I am getting this error message:

Error at line 1
ORA-06502: PL/SQL: numeric or value error 
ORA-06512: in "SYS.UTL_MAIL", line 654
ORA-06512: in "SYS.UTL_MAIL", line 671
ORA-06512: in "APPS.PR_MAIL_ME", line 44
ORA-06512: in line 2

This is my code, my cursor:

  cursor email_detail is
  select email
    from
    (
       <the subquery>
      )
   where rn = 1
     and status in ('WARNING','ERROR','STAND BY'); 

Then, i want to pass every single email inside utl_mail.send function using a LOOP

begin

  for c in email_detail
  loop
    begin

      utl_mail.send(sender => 'send@mail.com',recipients => c.email ,subject => 'Concurrents' ,message => 'adasdas');
    end;  
  end loop;

end;

I've tried so many times to solve this but i failed, could you please help me to solve this?


回答1:


In 11g, you will need to execute following commands before using utl_mail package:

@rdbms/admin/utlmail.sql
@rdbms/admin/prvtmail.plb
grant execute on utl_mail to <your_user_or_public>

Now, the important step is, you need to add the address and port of the e-mail server to the “smtp_out_server” initialization parameter. If you do not do this, you will receive a “ORA-06502: PL/SQL: numeric or value error” error when you try to use the UTL_MAIL package.

See this oracle documentation for more details on smtp_out_server.

Cheers!!



来源:https://stackoverflow.com/questions/59441036/error-while-passing-email-inside-utl-mail-send-oracle-11g-sql-06502-06512

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!