ORA-00920

ORA-00920: invalid relational operator tips is a syntax issue and can easily be resolved with the addition or removal of relational operators within the Oracle language. A relational operator is a construct that defines relation between two entities. In order to define this relation correctly, the code must follow the correct logic as well as the format specific to Oracle. The ORA-00920: invalid relational operator tips message will prompt you to correct this mistake within your code which should be fairly simple to resolve.

 

The Problem

ORA-00920: invalid relational operator tips occurs due to an invalid relational operator. Official Oracle documentation states that the cause is due to a search condition that was entered with an invalid or missing relational operator. It can also occur if an SQL statement with a WHERE clause includes an invalid relational operator. As mentioned previously, you must follow Oracle standards in defining the relationship between two entities in order for the code to run properly.

 

The Solution

To resolve the error, locate the specific place in which you are either missing the relational operator or using an incorrect relational operator.

The following is a list of valid relational operators:
=, !=, ^=, <>,<, <=, >, >=, ALL, ANY, BETWEEN, NOT BETWEEN, EXISTS, NOT EXISTS, IN, NOT IN, IS NULL, IS NOT NULL, LIKE, NOT LIKE

Take the following example.

SELECT *
FROM employees
WHERE employee_name is null;

In this example, the operator null in the third line is missing the word “is,” making the relational operator incorrect. While the missing word seems trivial, ORA-00920: invalid relational operator tips will be thrown if it does not follow the correct name and format. The code should read:

SELECT *
FROM employees
WHERE employee_name is null;

The following is another PL/SQL example:

SELECT *
FROM customers
WHERE (customer_name, customer_type) =
(
(‘PLSQL_PROFILER_RUNS’, ‘TABLE’),
(‘PLSQL_PROFILER_UNITS’, ‘TABLE’),
(‘PLSQL_PROFILER_DATA’, ‘TABLE’)
);

In this example, the values on either side of the operator “=” are not equal. In other words, we are selecting from a number of lists on the right side of the operator. To correctly run this code, simply insert the relational operator “IN” and eliminate the “=”:

SELECT *
FROM customers
WHERE (customer_name, customer_type) IN
(
(‘PLSQL_PROFILER_RUNS’, ‘TABLE’),
(‘PLSQL_PROFILER_UNITS’, ‘TABLE’),
(‘PLSQL_PROFILER_DATA’, ‘TABLE’)
);

As seasoned programmers may already know, Oracle errors can sometimes be misleading and throw errors that do not point to the real problem at hand. If you cannot detect any missing or misplaced relational operators, double-check your parentheses and commas. Missing parentheses or commas have been known to throw this error. A good integrated development environment application should be able to alert you to these very basic yet necessary syntax rules of Oracle.

 

Moving Forward

To avoid seeing ORA-00920: invalid relational operator tips in the future, become well versed in relational operators and how they work. Find a summary of operators here. These relational operators will be used often in your code and therefore, should be well known and familiar to you as a programmer.

If you continue to face problems with this particular error, you may consider contacting your database administrator for assistance if you yourself are not the DBA. Another option may be to contact an Oracle professional to resolve the issue. Remember to always check the consultant’s credentials and certification to ensure your Oracle needs are properly met.

STILL HAVE QUESTION?

Submit your question