How to convert column value to CamelCase with Oracle?
I guess a combination of initcap()
and replace()
would work:
select replace(initcap('hi ben'),' ') from dual;
REPLA
-----
HiBen
This simply capitalises the first character of every word and then replaces the spaces with nothing.
It obviously won't work if the first character is numeric:
select replace(initcap('go 2stack overflow'),' ') from dual;
REPLACE(INITCAP(
----------------
Go2stackOverflow
That's not my understanding of camelCase
select substr(lower('Camel Case means the first char should be lower cased'),1,1)||substr(replace(initcap('Camel Case means the first char should be lower cased'),' '),2) from dual;
camelCaseMeansTheFirstCharShouldBeLowerCased
1 row selected.