In Oracle, the COS()
function returns the cosine of its argument.
Syntax
The COS()
function’s syntax goes like this:
COS(n)
Where n
is any numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type.
Example
Here’s an example to demonstrate:
SELECT COS(2)
FROM DUAL;
Result:
COS(2) ____________________________________________ -0.41614683654714238699756822950076218977
Null Values
Passing null
to COS()
returns null
:
SET NULL 'null';
SELECT COS(null)
FROM DUAL;
Result:
COS(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 COS()
without passing any arguments returns an error:
SELECT COS()
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT COS() 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 COS(1, 2)
FROM DUAL;
Result:
Error starting at line : 1 in command - SELECT COS(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: