How to Change Negative Value to Positive in Oracle?

  • PLSQL / SQL
  • 1 min read

In Oracle, use ABS function to change negative value to positive value. This function takes as an argument any numeric data type and returns the absolute value.

Syntax

ABS(n)

Oracle ABS Function Examples

1. Using Select Statement

SELECT ABS(-15) Positive_value FROM DUAL;

Output

POSITIVE_VALUE
--------------
15
1 row selected.

2. Using PL/SQL Block

SET SERVEROUTPUT ON;
DECLARE
n_value NUMBER;
BEGIN
n_value := ABS(-9);
DBMS_OUTPUT.PUT_LINE (n_value);
END;
/

Output

9
PL/SQL procedure successfully completed.

See also