INITCAP
is a single row character function.- It takes a string and converts first character of each word to upper case and keeps all other letters in lower case.
- For any input string
INITCAP
identifies words delimited either by white space or characters that are not alpha-numeric. - The return value has the same data type as the argument CHAR type (CHAR or VARCHAR2).
Syntax: INITCAP(Character String)
SELECT 'the code man' Name, INITCAP('the code man') Init_Name FROM DUAL; NAME INIT_NAME ------------ ------------ the code man The Code Man
SELECT 'The Code Man' Name, INITCAP('The Code Man') Init_Name FROM DUAL; NAME INIT_NAME ------------ ------------ The Code Man The Code Man
SELECT 'THe CoDE maN' Name, INITCAP('THe CoDE maN') Init_Name FROM DUAL; NAME INIT_NAME ------------ ------------ THe CoDE maN The Code Man
SELECT 'THE CODE MAN' Name, INITCAP('THE CODE MAN') Init_Name FROM DUAL; NAME INIT_NAME ------------ ------------ THE CODE MAN The Code Man
SELECT 'THECODE man' Name, INITCAP('THECODE man') Init_Name FROM DUAL; NAME INIT_NAME ----------- ----------- THECODE man Thecode Man
Q: How INITCAP function identifies the different words in a particular string for its operation?
Ans: INITCAP
identifies different words for its operation by considering the delimiter as white space or any special characters encountered in the argument string. INITCAP
treats all characters as special character except alphanumeric values.
SELECT '[email protected]' Actual_Email, INITCAP('[email protected]') Init_Email FROM DUAL; ACTUAL_EMAIL INIT_EMAIL ----------------------- ----------------------- [email protected] [email protected]
SELECT 'info#the [email protected]' Actual_Email, INITCAP('info#the [email protected]') Init_Email FROM DUAL; ACTUAL_EMAIL INIT_EMAIL ---------------------------------- ---------------------------- info#the [email protected] Info#The [email protected]
SELECT 'sample [email protected]!demo' Actual_Str, INITCAP('sample [email protected]!demo') Init_Str FROM DUAL; ACTUAL_STR INIT_STR ---------------------------- ---------------------------- sample [email protected]!demo Sample [email protected]!Demo