Oracle ASIN() Function

Oracle ASIN() is a built-in function that returns the arcsine of a given number.

Oracle ASIN() syntax

Here is the syntax for the Oracle ASIN() function:

ASIN(num)

Parameters

num

Required. It must be between -1and 1.

It can be any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type.

Return Value

The Oracle ASIN() function returns the arcsine of a given number. It is a value in the range -pi/2 to pi/2, expressed in radians.

If the parameter is of type BINARY_FLOAT, ASIN() returns a BINARY_DOUBLE. Otherwise, ASIN() returns the same data type as the parameter.

If the parameter is not between -1 and 1, the ASIN() function will report an error.

If any parameter is NULL, ASIN() will return NULL.

Oracle ASIN() Examples

Here are some examples that demonstrate the usage of the Oracle ASIN() function.

Basic Usage

SELECT
    ASIN(0.5)
FROM dual;

Output:

                                  ASIN(0.5)
___________________________________________
   0.52359877559829887307710723054658381405

1 and -1

SELECT
    ASIN(1),
    ASIN(-1)
FROM dual;

Output:

                                   ASIN(1)                                    ASIN(-1)
__________________________________________ ___________________________________________
   1.5707963267948966192313216916397514421    -1.5707963267948966192313216916397514421

Out of range

If the parameter is not between -1and 1, the ASIN() function will report an error.

SELECT
    ASIN(2),
    ASIN(-2)
FROM dual;

Output:

SQL Error: ORA-01428: parameter '2' is out of range
01428\. 00000 -  "parameter '%s' is out of range"

Non-Numeric Values

If the parameter cannot be converted to a number, ASIN() will give an error.

SELECT
  ASIN('ABC')
FROM dual;

Output:

01722\. 00000 -  "invalid number"
*Cause:    The specified number was invalid.
*Action:   Specify a valid number.

NULL Parameters

If any parameter is NULL, ASIN() will return NULL.

SET NULL 'NULL';
SELECT
    ASIN(NULL)
FROM dual;

Output:

   ASIN(NULL)
_____________
         NULL

In this example, we use the statement SET NULL 'NULL'; to display NULL values as the string 'NULL'.

Conclusion

Oracle ASIN() is a built-in function that returns the arcsine of a given number.