oracle sql - 游标的上或下无关紧要

oracle sql -not matter upper or lower in cursor

输入一个域名在数据库中搜索,无论是高域名还是低域名,只要alpha匹配即可。

例子。 'hotmail.com'在数据库中,如果我输入'hOTmAIL.Com'。它仍然找到了域名 'hotmail.com'.

cursor E_info is select Email_Address from broker
where REGEXP_LIKE (substr(Email_Address, instr(Email_Address,'@')+1), old_email);

您可以在不使用 regexp_like 的情况下执行此操作。

Lower

select * from test where lower(substr(email_address,instr(email_address,'@')+1))=lower('HotMail.com');

与 regexp_like 相比,这将 return 结果更快,因为您正在执行完全匹配。

编辑

create or replace procedure PR_Q3
(old_email in varchar2, new_email in varchar2)
authid current_user
is 
cursor E_info is select Email_Address from test where lower(substr(email_address,instr(email_address,'@')+1))=lower(old_email);
v_email E_info%rowtype;
begin 
open E_info;
loop
fetch E_info into v_email;
exit when E_info%notfound;
update test set 
Email_Address = replace(Email_Address,substr(Email_Address,instr(Email_Address,'@')+1),new_email) 
where Email_Address = v_email.Email_Address;
end loop;
close E_info;
end PR_Q3;
/
create or replace procedure PR_Q3
(old_email in varchar2, new_email in varchar2)
authid current_user
is 
cursor E_info is select Email_Address from broker
where REGEXP_LIKE (substr(Email_Address, instr(Email_Address,'@')+1), old_email);
v_email E_info%rowtype;
begin 
open E_info;
loop
fetch E_info into v_email;
exit when E_info%notfound;
update broker set 
Email_Address = replace(Email_Address,substr(Email_Address,instr(Email_Address,'@')+1),new_email) 
where Email_Address = v_email.Email_Address;
end loop;
close E_info;
end PR_Q3;