ORA-00920 [42000]:无效的关系运算符

时间:2018-01-03 16:08:01

标签: sql oracle

以下是用于生成以下

的数据库选择的SQL源代码
  

错误:“查询执行失败,原因:SQL错误[920] [42000]:   ORA-00920:opérateur关系非valide。

请帮助!

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'

(我们在名为'fournisseur'的模式中选择)

提前感谢您的帮助。

2 个答案:

答案 0 :(得分:4)

问题发生在line 25,因为WHERE fll.noliv在此声明之后没有任何关系运算符,如<>!=

答案 1 :(得分:2)

TOTAL_PRIX似乎无效;看看它的WHERE子句:

(
                SELECT SUM(fll.prix_achat * fll.qte)
                FROM   fourniture.frnt_livraison_ligne fll
                WHERE  fll.noliv ), 0)                          AS total_prix,