I have a question about how to using a CURSOR to update an email domain name by using an new email domain name. ex(gmail.com->hotmail.com)
execute procedure('gmail.com','hotmail.com' )
Here is what I write. please help me out, thank you!
create procedure PR_Q3
is P_NewEamil varchar2(50); P_Email_Address varchar2(50); exceptionforemail exception;
cursor E_info is select Email_Address from Broker where P_Email_Address = 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 P_Email_Address = Email_Address;
Why you want to use the cursor when it can be done using a simple update
statement as following:
UPDATE BROKER
SET
EMAIL_ADDRESS = REPLACE(P_NEWEAMIL, :OLD_DOMAIN, :NEW_DOMAIN)
WHERE
REGEXP_LIKE ( P_NEWEAMIL,'.*@'|| :OLD_DOMAIN|| '$' );
Please add more WHERE
conditions according to your requirements.
Cheers!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.