ORA-00920: invalid relational operator

ORA-00920: invalid relational operator error occurs when a SQL query’s WHERE clause contains an invalid relational operator. Below is a list of the relational operators. Oracle could not find the relationship between two operands in the sql query if the WHERE clause uses a relational operation other than those listed. In this case, the error ORA-00920: invalid relational operator will be displayed in the oracle. Oracle does not recognize the invalid relational operator, therefore the WHERE clause of the sql query could not be executed. In this situation, the sql query will fail to execute.

The relational operators compare two values and return a boolean value, TRUE or FALSE. When the two operands are compared using the relational operator, the result is TRUE or FALSE. Relationship operators that are not supported by Oracle are considered invalid. Oracle will throw an error ORA-00920: invalid relational operato if any invalid relational operators are used in a sql query.

The relational operators supported in oracle are =, !=, ^=, <>,<, <=, >, >=, ALL, ANY, IN, NOT IN, BETWEEN, NOT BETWEEN, LIKE, NOT LIKE, EXISTS, NOT EXISTS, IS NULL, IS NOT NULL .



When the ORA-00920 error occurs

If you use an invalid relational operator between two operands in the SQL query’s WHERE clause, Oracle will be unable to determine the relationship between the two operands. The sql query’s WHERE clause was unable to complete the request. The sql query will not be executed. The Oracle error ORA-00920: invalid relational operato will be thrown in this scenario.

Program

select * from employee where id=>1;

Error

ORA-00920: invalid relational operator
00920. 00000 -  "invalid relational operator"
*Cause:    
*Action:


Root Cause

The relational operators compare two values and return a boolean value of TRUE OR FALSE. In programming, relational operators are used to make decisions. The relation could not be found if the relational operations used in the Oracle SQL query were incorrect. The sql query was unable to be executed. Oracle-supported relational operators should be used in the WHERE clause of a sql query



Solution 1

If the relational operator used in the WHERE clause is not in the list of those supported by Oracle, replace it with one that is. The relational operator might be misplaced or incorrectly written. To correct the error, change the relational operator in the WHERE clause. The relational operator should be one of the ones listed above.

Program

select * from employee where id=>1;

ORA-00920: invalid relational operator
00920. 00000 -  "invalid relational operator"

Solution

select * from employee where id >= 1;


Solution 2

Oracle could not identify the relational operator if the closing parenthesis was missed in the WHERE clause. The invalid relational operator error message will be shown. Oracle could not identify the relational operator in the WHERE clause if the open and close parentheses were misplaced or inserted extra in the sql query. If there is an issue with the open and close parenthesis, return to the query and rectify the problem. This will resolve the error.

Program

select * from employee where ltrim(name))='yawin';

ORA-00920: invalid relational operator
00920. 00000 -  "invalid relational operator"

Solution

select * from employee where ltrim(name) ='yawin';


Solution 3

The NOT operator should be placed in the correct order in the WHERE clause, if the NOT operator is misplaced in the sql query, the invalid relational operator error will be displayed. The NOT operator will be as follows, NOT IN, NOT LIKE, NOT BETWEEN, NOT EXISTS, IS NOT NULL.

Program

select * from employee where id not is null;

ORA-00920: invalid relational operator
00920. 00000 -  "invalid relational operator"

Solution

select * from employee where id is not null;



Leave a Reply