Oracle General Function Examples

  • Updated
  • Posted in Programming
  • 2 mins read


The basic features work with any knowledge kind and are primarily used to deal with null values. The Oracle basic features are

Oracle NVL Function

The syntax of NVL perform is

NVL(expr1, expr2)

The NVL perform takes two arguments as its enter. If the primary argument is NULL, then it returns the second argument in any other case it returns the primary argument.

SELECT NVL(10,2) FROM DUAL;
SELECT NVL(NULL,'Oracle') FROM DUAL;
SELECT NVL(NULL,NULL) FROM DUAL;

Oracle NVL2 Function

The syntax of NVL2 perform is

NVL2(expr1,expr2,expr3)

The NVL2 perform takes three arguments as its enter. If the expr1 is NOT NULL, NVL2 perform returns expr2. If expr1 is NULL, then NVL2 returns expr3.

SELECT NVL2('Ora','SID','TNS') FROM DUAL;
SELECT NVL2(NULL,'SID','TNS') FROM DUAL;

Oracle NULLIF Function

The Syntax of NULLIF perform is

NULLIF(expr1, expr2)

The NULLIF perform compares the 2 expressions and returns NULL if they’re equal in any other case it returns the primary expression.

SELECT NULLIF('Oracle','MYSQL') FROM DUAL;
SELECT NULLIF('MYSQL','MYSQL') FROM DUAL;

Oracle COALESCE Function

The Syntax of COALESCE perform is

COALESCE(expr1,expr2,expr3,...)

The COALESCE perform takes N variety of arguments as its enter and returns the primary NON-NULL argument.

SELECT COALESCE('DB Backup','Oracle') FROM DUAL;
SELECT COALESCE(NULL,'MYSQL',NULL) FROM DUAL;

Leave a Reply