Ошибка ora 00920 invalid relational operator

You get this error in Oracle when you are missing a comparison operation, such as = — as John Maillet already noted.

My concern is the second part of the where clause:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date('MIN_DATE', 'YYYYMMDDHH24MISS')

You have MIN_DATE in single quotes. This is interpreted as a string with eight letters in it, starting with 'M' and ending with 'E'. This is not interpreted as a variable. Presumably you mean:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date(MIN_DATE, 'YYYYMMDDHH24MISS')

You should only use single quotes for string and date constants.

I should add that you should be able to do this comparison without having to convert to dates:

where left(COLUMN_NAME, 14) = MIN_DATE

ORA-00920

ORA-00920: неправильный реляционный оператор

Причина:

Условие поиска было введено с неправильным или пропущенным реляционным оператором.

Действие:

Включите правильный реляционный оператор такой как =, !=, ^=, <>, >, <, >=, <=, ALL, ANY, NOT BETWEEN, NOT EXISTS, NOT IN, IS NOT NULL, или NOT LIKE.

You get this error in Oracle when you are missing a comparison operation, such as = — as John Maillet already noted.

My concern is the second part of the where clause:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date('MIN_DATE', 'YYYYMMDDHH24MISS')

You have MIN_DATE in single quotes. This is interpreted as a string with eight letters in it, starting with 'M' and ending with 'E'. This is not interpreted as a variable. Presumably you mean:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date(MIN_DATE, 'YYYYMMDDHH24MISS')

You should only use single quotes for string and date constants.

I should add that you should be able to do this comparison without having to convert to dates:

where left(COLUMN_NAME, 14) = MIN_DATE

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-00920 error message in Oracle.

Description

When you encounter an ORA-00920 error, the following error message will appear:

  • ORA-00920: invalid relational operator

Cause

You tried to execute a SQL statement, but the WHERE clause contained an invalid relational operator.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Correct the WHERE clause. Valid relational operators are as follows:

=
!=
^=
<>
<
<=
>
>=
ALL
ANY
BETWEEN
NOT BETWEEN
EXISTS
NOT EXISTS
IN
NOT IN
IS NULL
IS NOT NULL
LIKE
NOT LIKE

oracle tutorial webinars

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.

Понравилась статья? Поделить с друзьями:
  • Ошибка ora 00913
  • Ошибка ora 01019
  • Ошибка optifine 1282
  • Ошибка ora 00900
  • Ошибка jvcu 520428