IORA-00904: Invalid Identifier when converting Radians to Degrees

oracle-12c

I am using this simple query in Oracle SQL Developer to basically convert a value in Radians to Degrees but I get error at the function itself.

SELECT Degrees(1.571) as ANGLE FROM DUAL;

Error: Ora-00904: "DEGREES": invalid identifier
00904. 00000 – "%s: invalid identifier"

I checked Oracle documentation and a function called DEGREES does exist. I tried changing the query to convert DEGREES to RADIANS but same error.

Can someone please advise what's wrong here? The database I am connecting to is Oracle 12cR1.

Thanks in advance.

Best Answer

The DEGREES function you refer to is not in the Oracle database code. It is in the JavaDB which is also known as Derby. There is a construct in MySQL called DEGREES so this may be what you were thinking of.

You can make your own function like this

CREATE OR REPLACE FUNCTION radians_to_degree(p_radian IN NUMBER)
   RETURN NUMBER IS
BEGIN
   RETURN p_radian * 0.0174533;
END radians_to_degree;