ACOS() Function in Oracle

In Oracle, the ACOS() function returns the arccosine (inverse cosine) of its argument.

In other words, it returns the value whose cosine is the argument.

Syntax

The ACOS() function’s syntax goes like this:

ACOS(n)

Where n must be in the range of -1 to 1.

The function returns a value in the range of 0 to pi (π), expressed in radians.

Example

Here’s an example to demonstrate:

SELECT ACOS(0.14)
FROM DUAL;

Result:

                                 ACOS(0.14) 
___________________________________________ 
   1.43033491208504081896464016633592262709

Out of Range Argument

The argument must be between -1 and 1. If it’s not, an error is returned.

Example:

SELECT ACOS(2)
FROM DUAL;

Result:

Error starting at line : 1 in command -
SELECT ACOS(2)
FROM DUAL
Error report -
ORA-01428: argument '2' is out of range

Null Values

Passing null to ACOS() returns null:

SET NULL 'null';

SELECT ACOS(null)
FROM DUAL;

Result:

   ACOS(NULL) 
_____________ 
         null 

By default, SQLcl and SQL*Plus return a blank space whenever a null value occurs as a result of a SQL SELECT statement.

However, you can use SET NULL to specify a different string to be returned. Here I specified that the string null should be returned.

Incorrect Argument Count

Calling ACOS() without passing any arguments returns an error:

SELECT ACOS()
FROM DUAL;

Result:

Error starting at line : 1 in command -
SELECT ACOS()
FROM DUAL
Error at Command Line : 1 Column : 8
Error report -
SQL Error: ORA-00909: invalid number of arguments
00909. 00000 -  "invalid number of arguments"
*Cause:    
*Action:

And passing the wrong number of arguments results in an error:

SELECT ACOS(1, 2)
FROM DUAL;

Result:

Error starting at line : 1 in command -
SELECT ACOS(1, 2)
FROM DUAL
Error at Command Line : 1 Column : 8
Error report -
SQL Error: ORA-00909: invalid number of arguments
00909. 00000 -  "invalid number of arguments"
*Cause:    
*Action: