I want to selec column names and convert to pascal case. My column names are like this:
- IMG_SAR_NAME
- INT_AKT_DESC
I want to split “_” names and convert to:
- ImgSarName
- IntAktDesc
I can get column names with sql
Select COLUMN_NAME from ALL_COL_COMMENTS WHERE TABLE_NAME="MY_TABLE;
But can not convert to pascalcase.
Advertisement
Answer
I don’t know if always the underscore is the separator, but if it is, you can do this:
SQL> select replace(initcap('IMG_SAR_NAME'),'_','') from dual ; REPLACE(IN ---------- ImgSarName SQL>
The Oracle INITCAP() function sets the first letter of each word in uppercase, all other letters in lowercase. Words are delimited by white space or characters that are not alphanumeric. A string whose first character in each word will be converted to uppercase and the rest characters will be converted to lowercase.