Monday, April 11, 2011

TRANSLATE function, Something new I learned


-- To remove all spaces from a string

SELECT TRANSLATE('abc dda XbY a b c z','1 ','1') test

FROM dual;

TEST
-------------
abcddaXbYabcz

-- in the same manner to remove any abc from this string
SELECT TRANSLATE('abcddafghabcp','1abc ','1') test
FROM dual;

TEST
------
ddfghp

-- Also to replace any abc with xyz
SELECT TRANSLATE('abcddafghabcp','1abc ','1xyz') test
FROM dual;

TEST
-------------
xyzddxfghxyzp

No comments:

Post a Comment