does a function exist like replace where you can replace multiple values?
Example that shows the idea but does not work is
SELECT REPLACE(field_a,'M','Monday','T','Tuesday')
FROM mytable
TIA
Printable View
does a function exist like replace where you can replace multiple values?
Example that shows the idea but does not work is
SELECT REPLACE(field_a,'M','Monday','T','Tuesday')
FROM mytable
TIA
I already spent 30 minutes at that site (before coming here) and could not find what I was looking for. the two closest things were replace and translate. neither seem to do what I want. I am sure I am just overlooking something really easy. or it might just exist, but I thought I would try here before I say it can't be done.
Look at decode function. Look at coalesce in 9i.
Hi
"Case" can do this for you as well
select CASE when field_a = 'M' ,'Monday'
when field_a = 'T' ,'TUESDAY'
when ...
else 'Not a Valid Day'
end
from your_table;
regards
Hrishy
If your input string is like: 'MWF' and you want 'MondayWednesdayFriday' as the result, the easiest is
REPLACE(REPLACE(REPLACE(instring,'M','Monday'),'W','Wednesday'),'F','Friday')
(generalise for 7 days . . .)
Thanks everyone for the responses. Stecal had what I needed in the decode function.