Home » SQL & PL/SQL » SQL & PL/SQL » ORA-01719: outer join operator (+) not allowed in operand of OR or IN (Oracle, 9 , windows)
ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613880] Tue, 13 May 2014 06:28 Go to next message
akifdadan
Messages: 1
Registered: May 2014
Location: Pune
Junior Member
My query is

SELECT
s.SIT_ID, -- identifiant du site
s.SIT_NUMG2R, -- LPAD removed due to G2R code extension
s.SIT_ZPID, --ZP SITE CODE -- Ran Sharing Lot 1
s.SIT_NOM, -- NOMSITE
s.SIT_COOXSIM, -- X_SIMU_SITE
s.SIT_COOYSIM, -- Y_SIMU_SITE
s.SIT_COOZSIM, -- Z_SIMU_SITE
s.REG_NUM, -- REGION
s.DEP_NUM, -- DEPART
NVL( z.ZGE_LIB, '') -- ZONE_MKG
FROM
SITE s,
ZONEGEO z,
REGION reg
WHERE
s.SIT_NUMG2R IS NOT NULL -- Le numero du site n'est pas vide
AND s.ZGE_ID = z.ZGE_ID (+)
AND s.REG_NUM = reg.REG_NUM
AND reg.REG_VIRT = 0
OR (s.sit_zpid is not null and s.sit_zpid not like 'ZP%');


The error that am getting is as follows :

ORA-01719: outer join operator (+) not allowed in operand of OR or IN
01719. 00000 - "outer join operator (+) not allowed in operand of OR or IN"
*Cause: An outer join appears in an or clause.
*Action: If A and B are predicates, to get the effect of (A(+) or B),
try (select where (A(+) and not B)) union all (select where (B)).
Error at Line: 19 Column: 17


Can some one help me with the correct query ?
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613881 is a reply to message #613880] Tue, 13 May 2014 06:37 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
Welcome to the forum..
please use the formatter http://www.dpriver.com/pp/sqlformat.htm

SELECT s.sit_id,-- identifiant du site 
       s.sit_numg2r,-- LPAD removed due to G2R code extension 
       s.sit_zpid,--ZP SITE CODE  -- Ran Sharing Lot 1 
       s.sit_nom,-- NOMSITE 
       s.sit_cooxsim,-- X_SIMU_SITE 
       s.sit_cooysim,-- Y_SIMU_SITE 
       s.sit_coozsim,-- Z_SIMU_SITE 
       s.reg_num,-- REGION 
       s.dep_num,-- DEPART 
       Nvl(z.zge_lib, '') -- ZONE_MKG 
FROM   site s, 
       zonegeo z, 
       region reg 
WHERE  s.sit_numg2r IS NOT NULL -- Le numero du site n'est pas vide 
       AND s.zge_id = z.zge_id (+) 
       AND s.reg_num = reg.reg_num 
       AND reg.reg_virt = 0 
        OR ( s.sit_zpid IS NOT NULL 
             AND s.sit_zpid NOT LIKE 'ZP%' ); 


Please check this link http://www.techonthenet.com/oracle/errors/ora01719.php

[Updated on: Tue, 13 May 2014 06:40]

Report message to a moderator

Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613882 is a reply to message #613881] Tue, 13 May 2014 06:43 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
As a workaround, you can use an inline view to achieve the desired effect:

SELECT e.lname
  FROM employee e,
       (SELECT dept_id
          FROM department
         WHERE NAME = 'ACCOUNTING') v
 WHERE e.dept_id(+) = v.dept_id;
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613887 is a reply to message #613880] Tue, 13 May 2014 06:56 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
akifdadan wrote on Tue, 13 May 2014 16:58
*Cause: An outer join appears in an or clause.
*Action: If A and B are predicates, to get the effect of (A(+) or B),
try (select where (A(+) and not B)) union all (select where (B)).


The answer is in your own post. The recommended action is to split the OR condition using UNION ALL.
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613891 is a reply to message #613880] Tue, 13 May 2014 07:10 Go to previous messageGo to next message
Michel Cadot
Messages: 68764
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

Quote:
Can some one help me with the correct query ?


First of all, is the query semantically correct?
Does it express the specifications?

Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613892 is a reply to message #613887] Tue, 13 May 2014 07:11 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3305
Registered: January 2010
Location: Connecticut, USA
Senior Member
Or use ANSI join syntax. Also, some Oracle native outer join restrictions were lifted in 11G.

SY.
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613893 is a reply to message #613892] Tue, 13 May 2014 07:16 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
AND s.zge_id = z.zge_id (+)  -->This One
       AND s.reg_num = reg.reg_num 
       AND reg.reg_virt = 0 
        OR ( s.sit_zpid IS NOT NULL -->This One
             AND s.sit_zpid NOT LIKE 'ZP%' ); 


Please check or set the join conditions.

[Updated on: Tue, 13 May 2014 07:17]

Report message to a moderator

Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613894 is a reply to message #613893] Tue, 13 May 2014 07:21 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
May be this link will help you..http://www.orafaq.com/forum/t/39354/
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613897 is a reply to message #613880] Tue, 13 May 2014 07:28 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
use equi joinos
why do you want use outer join?
What is your requirement?
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613899 is a reply to message #613897] Tue, 13 May 2014 07:43 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
suppose your query is like below..
SELECT * 
FROM   dept a, 
       emp b 
WHERE  a.deptno IS NOT NULL 
       AND a.deptno = b.deptno(+) 
        OR ( a.deptno IS NOT NULL 
             AND a.dname NOT LIKE 'AC%' ); 


And try with the below query..

SELECT DISTINCT ename 
FROM   emp a 
WHERE  EXISTS(SELECT 1 
              FROM   dept d 
              WHERE  a.deptno = d.deptno 
                      OR ( d.deptno IS NOT NULL 
                           AND d.dname NOT LIKE 'AC%' )) 
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613904 is a reply to message #613899] Tue, 13 May 2014 08:17 Go to previous messageGo to next message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
@mist - those queries aren't at all equivalent. They will return different rows and different columns.

OP has an outer-join because he wants to select records from a table where matching rows may not be present, and he still wants the data from the other table in that case. You can't use EXISTS as a replacement for that.
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613905 is a reply to message #613904] Tue, 13 May 2014 08:21 Go to previous messageGo to next message
mist598
Messages: 1195
Registered: February 2013
Location: Hyderabad
Senior Member
SELECT * 
FROM   emp b, 
       (SELECT * 
        FROM   dept a 
        WHERE  a.deptno IS NOT NULL 
               AND a.dname NOT LIKE 'AC%') a 
WHERE  b.deptno = a.deptno(+); 



This one right?
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613906 is a reply to message #613905] Tue, 13 May 2014 08:23 Go to previous messageGo to next message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
@akifdadan - I think you're missing some brackets. Your where clause is logically equivalent to:
WHERE (s.sit_numg2r IS NOT NULL -- Le numero du site n'est pas vide 
       AND s.zge_id = z.zge_id (+) 
       AND s.reg_num = reg.reg_num 
       AND reg.reg_virt = 0 
      )
      OR (s.sit_zpid IS NOT NULL 
          AND s.sit_zpid NOT LIKE 'ZP%' ); 

So either the 1st 4 lines must be true, or the last 2.
I doubt that's what you want and the OR should only be applied to one of the preceding lines, maybe this:
WHERE s.sit_numg2r IS NOT NULL -- Le numero du site n'est pas vide 
AND s.zge_id = z.zge_id (+) 
AND s.reg_num = reg.reg_num 
AND (reg.reg_virt = 0 
     OR (s.sit_zpid IS NOT NULL 
         AND s.sit_zpid NOT LIKE 'ZP%' 
        )
    ); 
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613909 is a reply to message #613906] Tue, 13 May 2014 08:28 Go to previous messageGo to next message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
mist598 wrote on Tue, 13 May 2014 14:21
SELECT * 
FROM   emp b, 
       (SELECT * 
        FROM   dept a 
        WHERE  a.deptno IS NOT NULL 
               AND a.dname NOT LIKE 'AC%') a 
WHERE  b.deptno = a.deptno(+); 



This one right?


I doubt it's relevant to the OPs problem, see my second post in this thread.
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613923 is a reply to message #613905] Tue, 13 May 2014 10:24 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
@mist598,
Why not let OP understand the suggested action in the error mesaage and tries it by his own. How would EXISTS solve the issue? Splitting the query using UNION ALL certainly would resolve, let's wait for OP's feedback.
Re: ORA-01719: outer join operator (+) not allowed in operand of OR or IN [message #613928 is a reply to message #613923] Tue, 13 May 2014 10:33 Go to previous message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
@Lalit - you should read my second post as well, splitting the query is not necessary, fixing the brackets is.
Previous Topic: Replace HTML codes with the special characters in CLOB data types.
Next Topic: Query To update a table
Goto Forum:
  


Current Time: Thu Jul 31 01:03:12 CDT 2025