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;
SELECT S_OPTY.ROW_ID,
S_OPTY.CREATED,
S_OPTY.NAME,
S_OPTY.STG_START_DT,
S_OPTY.LEAD_QUALITY_CD,
S_OPTY.REASON_WON_LOST_CD,
S_OPTY.REVENUE_CLASS,
S_OPTY.PAR_OPTY_ID,
S_OPTY.CHANNEL_TYPE_CD,
S_OPTY.SUM_REVN_AMT,
S_OPTY.CURCY_CD,
S_OPTY.SUM_COMMIT_FLG,
S_OPTY.SUM_EFFECTIVE_DT,
S_OPTY.SUM_COST_AMT,
S_OPTY.SUM_WIN_PROB,
S_OPTY.CURR_STG_ID,
S_OPTY.SALES_METHOD_ID,
S_OPTY.DESC_TEXT,
S_OPTY.STATUS_CD,
S_OPTY.EXEC_PRIORITY_FLG,
S_ORG_EXT.NAME NAME1,
S_ORG_EXT.LOC,
S_STG.NAME NAME2,
S_STG.MAX_DAYS_IN_STAGE,
S_STG.STAGE_STATUS_CD,
S_OPTY_X.ATTRIB_05,
S_OPTY_X.ATTRIB_08,
S_OPTY_X.ATTRIB_09,
S_OPTY_X.ATTRIB_11,
S_OPTY_X.ATTRIB_37,
S_OPTY_X.ATTRIB_39,
S_OPTY_X.ATTRIB_43,
S_ADDR_ORG.ADDR,
S_ADDR_ORG.CITY,
S_ADDR_ORG.COUNTRY,
S_ADDR_ORG.STATE,
S_ADDR_ORG.ZIPCODE,
S_OPTY.BU_ID,
S_OPTY.PR_POSTN_ID,
S_OPTY.CREATED_BY,
S_OPTY.LAST_UPD_BY,
S_OPTY.LAST_UPD,
S_STG.LAST_UPD,
S_OPTY_X.LAST_UPD,
‘0’ AS X_CUSTOM,
S_OPTY.ACTL_CLS_DT,
S_OPTY.ASGN_DT,
S_OPTY.OPTY_CD,
S_OPTY.X_PR_CTLG_CAT_ID,
S_OPTY.X_ADOPT_YEAR,
S_OPTY.X_ADOPTION_PERIOD,
S_OPTY.X_ENROLLMENT,
S_OPTY.X_MEDIA_REQD_FLG,
S_OPTY.X_PIU_ACTION,
S_OPTY.X_RENTAL_FLG,
S_OPTY.X_RPT_PERIOD_FLG,
S_OPTY.X_STRATEGY,
S_OPTY.X_TERM_TYPE
FROM
V_OPTY S_OPTY,
S_OPTY_X,
S_ORG_EXT,
S_ADDR_ORG,
S_STG
WHERE
V_OPTY S_OPTY
LEFT OUTER JOIN S_OPTY_X ON
S_OPTY.ROW_ID = S_OPTY_X.PAR_ROW_ID
LEFT OUTER JOIN S_STG ON
S_OPTY.CURR_STG_ID = S_STG.ROW_ID AND
S_OPTY.SALES_METHOD_ID = S_STG.SALES_METHOD_ID
LEFT OUTER JOIN S_ORG_EXT ON
S_OPTY.PR_DEPT_OU_ID = S_ORG_EXT.ROW_ID
LEFT OUTER JOIN S_ADDR_ORG ON
S_ORG_EXT.PR_ADDR_ID = S_ADDR_ORG.ROW_ID
whats wrong with this sql statement?
Appreciate your help.
Thanks
Jay.
April 28, 2021
I got ” ORA-00920: invalid relational operator” error in Oracle.
ORA-00920: invalid relational operator
Details of error are as follows.
ORA-00920 invalid relational operator
Cause: A search condition was entered with an invalid or missing relational operator.
Action: Include a valid relational operator such as =, !=, ^=, <>, >, <, >=, <=, ALL,
ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition.
invalid relational operator
This ORA-00920 errors are related with the search condition was entered with an invalid or missing relational operator.
To solve this error, Include a valid relational operator such as =, !=, ^=, <>, >, <, >=, <=, ALL,
ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition.
Don’t forget using the relational operator in the where condition.
Do you want to learn Oracle Database for Beginners, then read the following articles.
Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )
1,275 views last month, 1 views today
Here is the SQL Source Code for database selection that generates the following
error: «Query execution failed, Reason: SQL Error [920] [42000]:
ORA-00920: opérateur relationnel non valide.
Please Help!
WITH adr_siege as (
SELECT Nvl(adr.libadr, ' ') AS libadr, Nvl(adr.adress, ' ') AS adress,
Nvl(adr.codpos, ' ') AS codpos, Nvl(adr.locali, ' ') AS locali,
Nvl(adr.codpay, ' ') AS codpay
FROM gnx.tie
JOIN gnx.adr
ON adr.codsoc = tie.codsoc
AND adr.typtie = tie.typtie
AND adr.sigadr = tie.sigtie
AND typadr = 'COM'
WHERE tie.typtie = 'DEP'
AND tie.codsoc=1
AND tie.sigtie = '00000137'
)
SELECT Nvl(a.codpro, ' ') AS codpro, Nvl(a.nompro, ' ') AS nompro,
Nvl(ll.prix_achat, 0) AS prix_achat, Nvl(ll.qte, 0) AS qte,
Nvl(l.nom_fournisseur, ' ') AS nom_fournisseur, Nvl(m.raison, ' ') AS raison,
Nvl(concat(m.adresse1,' ' || m.adresse2), ' ') AS adresse_mag,
Nvl(m.cp, ' ') AS cp, Nvl(m.ville, ' ') AS ville,
Nvl(p.libelle, ' ') AS libelle,
Nvl(To_Char(c.date_validation, 'DD/MM/YYYY'), ' ') AS date_validation,
Nvl((
SELECT sum(fll.prix_achat * fll.qte)
FROM fourniture.frnt_livraison_ligne fll
WHERE fll.noliv
), 0) AS total_prix,
To_Char(SYSDATE, 'DD/MM/YYYY') AS date_edition,
Nvl(f.libadr, ' ') AS fou_lib_adr,
Nvl(f.tel, ' ') AS fou_tel,
Nvl(f.adress, ' ') AS fou_adr, Nvl(f.codpos, ' ') AS fou_cp,
Nvl(f.locali, ' ') AS fou_ville, Nvl(pf.libelle, ' ') AS fou_pays,
Nvl(to_char(p.date_livraison_s1, 'DD/MM/YYYY'), ' ') AS date_livraison_s1,
Nvl(to_char(p.date_livraison_s2, 'DD/MM/YYYY'), ' ') AS date_livraison_s2,
Nvl((
SELECT tbl.lib1
FROM gnx.tie
LEFT JOIN gnx.tbl
ON tbl.codtbl = 'mrg'
AND tbl.lib1 IS NOT NULL
AND tbl.codsoc=1
AND tbl.cletbl = tie.modrgl
WHERE tie.typtie = 'FOU'
AND tie.sigtie = l.code_fournisseur
AND tie.codsoc =1
), ' ') AS mode_paiement,
l.num_sous_periode,
adr_siege.*,
Nvl(m.nummag, ' ') AS nummag,
Nvl(m.tel1, ' ') AS tel1,
l.ref_gnx,
Nvl(tva.taux_tva, 0)/100 AS taux_tva,
Nvl(f.code, ' ') AS code_fournisseur,
(
CASE WHEN (m.lundi_ouverture != '0' OR m.mardi_ouverture != '0' OR m.mercredi_ouverture != '0'
OR m.jeudi_ouverture != '0' OR m.vendredi_ouverture != '0' OR m.samedi_ouverture != '0') THEN 1
ELSE 0
END
) AS AFFICH_HORRAIRE,
a.conditionnement,
a.refpro as REFPRO
FROM adr_siege, fourniture.frnt_livraison l
INNER JOIN fourniture.frnt_livraison_ligne ll ON ll.noliv = l.noliv
INNER JOIN fourniture.frnt_article a ON a.codpro = ll.codpro
INNER JOIN fourniture.frnt_commande c ON c.nocde = l.nocde
INNER JOIN polymag.magasin m ON m.nummag = c.nummag
INNER JOIN polymag.pays p ON p.code = m.codepays
LEFT JOIN fourniture.frnt_fournisseur f ON f.code =l.code_fournisseur
INNER JOIN polymag.pays pf ON pf.code = f.codpay
INNER JOIN fourniture.frnt_periode p ON p.noperiode = c.noperiode
LEFT JOIN fourniture.frnt_tva tva ON tva.code_pays_fou = f.codpay AND tva.code_pays_mag = m.codepays
WHERE l.type_livraison = 'FOU'
(we are selecting in schema named ‘fournisseur’)
Thank you in advance for your help.
Here is the SQL Source Code for database selection that generates the following
error: «Query execution failed, Reason: SQL Error [920] [42000]:
ORA-00920: opérateur relationnel non valide.
Please Help!
WITH adr_siege as (
SELECT Nvl(adr.libadr, ' ') AS libadr, Nvl(adr.adress, ' ') AS adress,
Nvl(adr.codpos, ' ') AS codpos, Nvl(adr.locali, ' ') AS locali,
Nvl(adr.codpay, ' ') AS codpay
FROM gnx.tie
JOIN gnx.adr
ON adr.codsoc = tie.codsoc
AND adr.typtie = tie.typtie
AND adr.sigadr = tie.sigtie
AND typadr = 'COM'
WHERE tie.typtie = 'DEP'
AND tie.codsoc=1
AND tie.sigtie = '00000137'
)
SELECT Nvl(a.codpro, ' ') AS codpro, Nvl(a.nompro, ' ') AS nompro,
Nvl(ll.prix_achat, 0) AS prix_achat, Nvl(ll.qte, 0) AS qte,
Nvl(l.nom_fournisseur, ' ') AS nom_fournisseur, Nvl(m.raison, ' ') AS raison,
Nvl(concat(m.adresse1,' ' || m.adresse2), ' ') AS adresse_mag,
Nvl(m.cp, ' ') AS cp, Nvl(m.ville, ' ') AS ville,
Nvl(p.libelle, ' ') AS libelle,
Nvl(To_Char(c.date_validation, 'DD/MM/YYYY'), ' ') AS date_validation,
Nvl((
SELECT sum(fll.prix_achat * fll.qte)
FROM fourniture.frnt_livraison_ligne fll
WHERE fll.noliv
), 0) AS total_prix,
To_Char(SYSDATE, 'DD/MM/YYYY') AS date_edition,
Nvl(f.libadr, ' ') AS fou_lib_adr,
Nvl(f.tel, ' ') AS fou_tel,
Nvl(f.adress, ' ') AS fou_adr, Nvl(f.codpos, ' ') AS fou_cp,
Nvl(f.locali, ' ') AS fou_ville, Nvl(pf.libelle, ' ') AS fou_pays,
Nvl(to_char(p.date_livraison_s1, 'DD/MM/YYYY'), ' ') AS date_livraison_s1,
Nvl(to_char(p.date_livraison_s2, 'DD/MM/YYYY'), ' ') AS date_livraison_s2,
Nvl((
SELECT tbl.lib1
FROM gnx.tie
LEFT JOIN gnx.tbl
ON tbl.codtbl = 'mrg'
AND tbl.lib1 IS NOT NULL
AND tbl.codsoc=1
AND tbl.cletbl = tie.modrgl
WHERE tie.typtie = 'FOU'
AND tie.sigtie = l.code_fournisseur
AND tie.codsoc =1
), ' ') AS mode_paiement,
l.num_sous_periode,
adr_siege.*,
Nvl(m.nummag, ' ') AS nummag,
Nvl(m.tel1, ' ') AS tel1,
l.ref_gnx,
Nvl(tva.taux_tva, 0)/100 AS taux_tva,
Nvl(f.code, ' ') AS code_fournisseur,
(
CASE WHEN (m.lundi_ouverture != '0' OR m.mardi_ouverture != '0' OR m.mercredi_ouverture != '0'
OR m.jeudi_ouverture != '0' OR m.vendredi_ouverture != '0' OR m.samedi_ouverture != '0') THEN 1
ELSE 0
END
) AS AFFICH_HORRAIRE,
a.conditionnement,
a.refpro as REFPRO
FROM adr_siege, fourniture.frnt_livraison l
INNER JOIN fourniture.frnt_livraison_ligne ll ON ll.noliv = l.noliv
INNER JOIN fourniture.frnt_article a ON a.codpro = ll.codpro
INNER JOIN fourniture.frnt_commande c ON c.nocde = l.nocde
INNER JOIN polymag.magasin m ON m.nummag = c.nummag
INNER JOIN polymag.pays p ON p.code = m.codepays
LEFT JOIN fourniture.frnt_fournisseur f ON f.code =l.code_fournisseur
INNER JOIN polymag.pays pf ON pf.code = f.codpay
INNER JOIN fourniture.frnt_periode p ON p.noperiode = c.noperiode
LEFT JOIN fourniture.frnt_tva tva ON tva.code_pays_fou = f.codpay AND tva.code_pays_mag = m.codepays
WHERE l.type_livraison = 'FOU'
(we are selecting in schema named ‘fournisseur’)
Thank you in advance for your help.