oracle sql cursor update an email domain name 使用电子邮件域名

oracle sql cursor update an email domain name using an email domain name

我想给个域名换个新域名。该程序将传递两个字符串。 不使用主键而是使用电子邮件 执行程序('gmail.com', 'hotmail.com');

数据库中所有带'Gmail.com'的邮件都将更改为'Hotmail.com'的新域名。 这是我的代码。

我对 'wrong number or type of arguments in call to PR_Q3'

有错误
create procedure PR_Q3
is P_NewEamil varchar2(50); P_OldEmail varchar2(50);
cursor E_info is select Email_Address from Broker where P_OldEmail = Email_Address
for update of Email_Address;
begin 
open E_info;
fetch E_info into P_NewEamil;
while E_info%found loop 
if(P_NewEamil like '%.com') then 
update Broker set Email_Address = P_NewEamil where Email_Address= P_OldEmail;
else 

 end if;
end loop;
close E_info;

 end PR_Q3;

您的程序应如下所示:

create procedure PR_Q3(p_oldemail in varchar2,
                       p_newemail in varchar2)
As
Begin

UPDATE BROKER
SET
    EMAIL_ADDRESS = REPLACE(EMAIL_ADDRESS, p_oldemail, p_newemail)
WHERE
    REGEXP_LIKE ( EMAIL_ADDRESS,'.*@'|| p_oldemail|| '$' );

Commit;

End;
/

要调用此过程,您需要按以下方式传递两个域:

Begin
Pr_q3('gmail.com', 'hotmail.com');
End;
/

干杯!!