Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Replace Email Address 1

Status
Not open for further replies.

TStriker

Programmer
Nov 12, 2003
277
US
Hi all,

I have a table with a lot of email addresses. One of the companies that we deal with just changed their name and therefore all of their people have new addresses.

The syntax remains the same i.e. First_Last@Company.com so what I would like to to is make a mass change to all rows in the table substituting the only the 'Company' portion of the address.

Thanks.

-Striker
 
Code:
update EMAIL_ADDRESS_MASTER
set    USER_EMAIL =
       replace(USER_EMAIL,'Company.com','NewName.com')
where  COMPANY_ID = .....;

Try in a select first to make sure your where clause is getting the right rows.

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Wow that was easy! I look like a dope for not knowing the replace function was available. I looked for a function like it in an old Oracle training book but didn't find it anywhere.

Anyway, I tried it on a single row and it worked like a charm.

Thanks Mr. Cooper, you are a gentleman and a scholar.

-Striker
 
You are quite welcome - however what I really am is a lady coder!
[gorgeous]

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Oops. Holy cow, I'm oh for two now. I thought about that possibility when I made the post but went with the odds... and missed.

-Striker
 
I would write the update a little different,

update EMAIL_ADDRESS_MASTER
set USER_EMAIL =
replace(USER_EMAIL,'@Company.com','@NewName.com');

If you don't include the @, then someone with smith@abcd.com and jones@bcd.com would both change.


Bill
Oracle DBA/Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top