|
-
need something like Replace function
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.
Last edited by digiaks; 05-09-2003 at 09:37 PM.
-
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 . . .)
"The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman
-
Thanks everyone for the responses. Stecal had what I needed in the decode function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|