How to update the email ids for the thousand users through database.
Updating email ids means updating only the domain part of the email.
example a user has email as bc.xyz@bajajauto.com and now has to update as abc.xyz@atulauto.com
Here you need to update the part of the email id.
I have written the function for the same.
BEGIN
FOR user_ids in (SELECT user_id FROM user usr where usr.email like '%@bajajauto.com%')
LOOP
FOR user_email_id in (
SELECT SUBSTR(t.email, 0, INSTR(t.email, '@')-1) AS part_of_email, t.user_id FROM user t where t.user_id = user_ids.user_id)
)
LOOP
update user user2 set user2.email = user_email_id.part_of_email || '@atulauto.com' WHERE user2.user_id = user_email_id.user_id;
END LOOP;
END LOOP;
END;
Hope this would be useful. Let me know if it could be improved. Also if anyone knows any other quicker solution.