When using the TO_CHAR() function to format a number in Oracle Database, you can use the PR format element to return negative values inside angle brackets (<>).
Example
Here’s an example to demonstrate the PR format element:
SELECT
TO_CHAR(7, 'fm9PR') AS "Positive",
TO_CHAR(-7, 'fm9PR') AS "Negative"
FROM DUAL;
Result:
Positive Negative ___________ ___________ 7 <7>
Note that I used the fm format modifier here. The format modifier suppresses any padding that may be applied to the result.
In the case of the PR format element, it returns leading and trailing blanks on positive numbers.
Therefore, if we remove the fm modifier, we get the following:
SELECT
TO_CHAR(7, '9PR') AS "Positive",
TO_CHAR(-7, '9PR') AS "Negative"
FROM DUAL;
Result:
Positive Negative ___________ ___________ 7 <7>
If you look closely, you’ll see that the positive number is indented by one space. This is due to the leading blank.