SQL Error: ORA-00919: incorrect function error occurs when an error occurs while calling a function in the VALUES clause of the insert statement. Oracle insert statement allows you to use any Oracle function for the values in the VALUES clause. If an error happens when executing the function in the insert statement, the error will be shown. Oracle was unable to find the function or found an invalid function. The insert statement was unable to store the value into the table. The invalid function should be deleted, or the function problem should be resolved. Otherwise, Oracle will show an error message SQL Error: ORA-00919: incorrect function.
The syntax error is mostly cause for the incorrect function error in the insert statement. There might be a syntax error in and surrounding the function call, such as a missing comma or single quotes, for example. Due to the syntax errors, the function added to the VALUES class of the insert statement could not be executed. As a result, the insert statement was unable to store the value in the database table. The error SQL Error: ORA-00919: incorrect function will be thrown in this scenario.
When the ORA-00919 error occur
The Oracle function could not be performed if there was a syntax error in and around the function call used in the VALUES clause of the insert statement. The insert statement will fail to store the values in the table. Create an insert statement with a function call in the VALUES clause. Create a syntax error in and around the function call. The error message SQL Error: ORA-00919: incorrect function will be shown if you execute the insert statement.
Program
insert into stud values(1,substr('Yawin Tutor',1).'Oracle');
Error
Error starting at line : 29 in command -
insert into stud values(1,substr('Yawin Tutor',1).'Oracle')
Error at Command Line : 29 Column : 51
Error report -
SQL Error: ORA-00919: invalid function
00919. 00000 - "invalid function"
Root Cause
Oracle’s insert statement allows you to include a function call in the VALUES clause. The insert statement could not execute the function call if there was a syntax error in and surrounding the function. The insert statement does not successfully insert values into the table. The syntax error should be discovered and corrected in the insert statement’s VALUES clause. The most typical cause of this issue is a missing comma or missing single quotes. If you fix the issue, the error SQL Error: ORA-00919: incorrect function will be resolved.
Solution 1
If the error occurs in the insert statement, go back and look at the VALUES clause. If the VALUES clause of the insert statement involves a function call, check the function call and analyze the code for any syntax errors in and around the function call. If an error occurs while invoking the function or a syntax error occurs, solve the problem. This will fix the error SQL Error: ORA-00919: incorrect function
In the insert statement’s VALUES clause, a comma is missing after the function call in the example below. A comma operator should be used instead of the dot operator. This will fix the insert statement error.
Program
insert into stud values(1,substr('Yawin Tutor',1).'Oracle');
Error
Error report -
SQL Error: ORA-00919: invalid function
00919. 00000 - "invalid function"
Solution
insert into stud values(1,substr('Yawin Tutor',1), 'Oracle');
A dot operator is inserted after the substr function in the following insert statement. The dot operator is used to call a function within an object. The function was unable to call another function. A function can be used as a parameter in another function. The dot operator cannot be used in this situation. The actual error in the above insert statement is the use of a dot operator instead of a comma operator. The comma operator is used to distinguish the list of values in the insert statement’s VALUES clause.