Oracle INITCAP() Function

Oracle INITCAP() is a built-in function that capitalizes the first letter of each word in a given string and converts all other letters to lowercase.

Oracle INITCAP() Syntax

Here is the syntax for the Oracle INITCAP() function:

INITCAP(str)

Parameters

str

Required. It can be any data type from CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The function does not directly support CLOB data. However, CLOB values can be passed as arguments through implicit data conversion.

Return Value

The Oracle INITCAP() function returns a string that capitalizes the first letter of each word in the specified string and converts all other letters to lowercase.

If any of the arguments are NULL, INITCAP() will return NULL.

Oracle INITCAP() Examples

Here are some examples that demonstrate the usage of the Oracle INITCAP() function.

Basic Usage

SELECT
    INITCAP('hello world')
FROM dual;

Output:

INITCAP('HELLOWORLD')
________________________
Hello World

or

SELECT
    INITCAP('HELLO WORLD') "INITCAP('HELLO WORLD')"
FROM dual;

Output:

INITCAP('HELLO WORLD')
_________________________
Hello World

NULL Parameter

If any of the arguments are NULL, INITCAP() will return NULL.

SET NULL 'NULL';
SELECT
    INITCAP(NULL)
FROM dual;

Output:

INITCAP(NULL)
________________
NULL

In this example, we use the SET NULL 'NULL'; statement to display the NULL value as the string 'NULL'.

Conclusion

Oracle INITCAP() is a built-in function that capitalizes the first letter of each word in a given string and converts all other letters to lowercase.