首页 > 解决方案 > 在过程(消息)中传递参数不起作用 - oracle

问题描述

我想创建一个过程,但在函数内部传递参数时遇到问题

这是我的代码:

  select 'The concurrent '||program||' with request_id '||request_id||' ended with status '|| 
           status as message, request_id
    from
    (
       <the subquery>
      )
   where rn = 1
     and status in ('WARNING','ERROR','STAND BY');   

它工作得很好,每次运行时我都会得到这个输出:

|The concurrent Sales with request_id 987987678 ended with status WARNING|987987678 

现在,我想使用上面编写的查询创建一个 PROCEDURE .. 我想发送一封包含该信息的邮件

这是我到目前为止得到的:

create or replace procedure pr_mail_me is

  v_email_test varchar2(100) := 'myemail@random.com';

cursor crs_request is

  select 'The concurrent '||program||' with request_id '||request_id||' ended with status '|| 
           status as message, request_id
    from
    (
       <the subquery>
      )
   where rn = 1
     and status in ('WARNING','ERROR','STAND BY');  

begin

  for c in crs_request
  loop
  begin


      utl_mail.send(sender => 'sendercompany@test.com',recipients => v_email ,subject => 'Concurrents' ,message => c.message);
   end;
  end loop;

end;

但这不起作用。我想接收邮件,这就是我使用这个 oracle 函数utl_mail.send的原因

我需要在邮件中收到此消息:

request_id 为 987987678 的并发销售以状态 WARNING 结束

另外,我怎样才能将此消息发送给许多其他人?我可以使用相同的变量 v_email_test

标签: sqloraclestored-proceduresoracle11g

解决方案


推荐阅读