NVL Function - Oracle to MariaDB Migration

In Oracle, the NVL function allows you to replace NULL with the specified expression i.e. it returns the first operand if it is not NULL, otherwise it returns the second operand.

MariaDB also provides the NVL function MariaDB 10.3.1 in both native and Oracle compatibility modes, so no conversion is required.

Before MariaDB 10.3.1 you can convert Oracle NVL function to MariaDB IFNULL function.

Oracle:

  -- Replace NULL
  SELECT NVL('John', 'N/A') FROM dual;
  # John
 
  -- Replace NULL
  SELECT NVL(NULL, 'N/A') FROM dual;
  # N/A

MariaDB:

  -- Replace NULL
  SELECT NVL('John', 'N/A');
  # John
 
  -- Replace NULL
  SELECT NVL(NULL, 'N/A');
  # N/A

For more information, see Oracle to MariaDB Migration.