Link to home
Start Free TrialLog in
Avatar of CalmSoul
CalmSoulFlag for United States of America

asked on

replace function in oracle

Hello Experts:

I two columns in ORA table with NAS path i.e.

\\folder1\folder2\folder3\some file name1.doc
\\folder1\folder2\folder3\some file name2.doc
\\folder1\folder2\folder3\some file name3.doc
\\folder1\folder2\folder3\some file name4.doc

Open in new window


I would like to replace it with new NAS path \\folder4\folder5\folder6\

output like this

 \\folder4\folder5\folder6\some file name1.doc
 \\folder4\folder5\folder6\some file name2.doc
 \\folder4\folder5\folder6\some file name3.doc
 \\folder4\folder5\folder6\some file name4.doc

Open in new window


Can somebody please assist with this update query?

Regards,
CS
Avatar of Walter Ritzel
Walter Ritzel
Flag of Brazil image

update table
set column = replace(column,'\\folder1\folder2\folder3\','\\folder4\folder5\folder6\')
where key = < value>;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also accomplish the above without the replace function -
update yourtable
set path =  '\\folder4\folder5\folder6'||substr(path,instr(path,'\',-1))
where path like '\\folder1\folder2\folder3\%';

However, since you mention two columns, are you trying to replace the path in one column with the path from another column? If so, could you provide some sample data for both columns and your expected output?