Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Wil.

Asked: June 13, 2002 - 7:02 pm UTC

Last updated: October 13, 2005 - 10:34 am UTC

Version: 8.1.7

Viewed 1000+ times

You Asked


Hi Tom,

I cannot find nor can I make up examples for the following
restrictions mentioned in Oracle documentation.

1. Select query for a view cannot have any reference to currval or nextval. Whatever I try seems to work

2. Outer join cannot have "OR" , "IN" operators

While it is easy to makeup an example for "OR" restriction, I
can't find a good example of "IN" restriction.

Can you please provide one or two examples showing how select
statements run into error because of these restrictions mentioned above.

Regards

Wil

and Tom said...

scott@ORA817DEV.US.ORACLE.COM> create or replace view v
2 as
3 select seq.nextval x from dual;
select seq.nextval x from dual
*
ERROR at line 3:
ORA-02287: sequence number not allowed here


scott@ORA817DEV.US.ORACLE.COM>
scott@ORA817DEV.US.ORACLE.COM> select * from dual where dummy(+) in (1,2,3);
select * from dual where dummy(+) in (1,2,3)
*
ERROR at line 1:
ORA-01719: outer join operator (+) not allowed in operand of OR or IN

Rating

  (6 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

sequence in views

Suresh, June 13, 2002 - 10:38 pm UTC

Tom,
Any specific reason why sequences are not allowed in Views? Thanks.

Tom Kyte
June 14, 2002 - 7:17 am UTC

don't know why the restriction exists.

why cant we ...

bole taro dolbaje, June 20, 2002 - 6:29 pm UTC

what about the below restriction..
ORA-01719: outer join operator (+) not allowed in operand of OR or IN

why so ?

Tom Kyte
June 20, 2002 - 8:41 pm UTC

sometimes -- just because. It is the way things are.

Same answer as the answer to the followup right above.


I can say in 9i, the restriction is removed:

scott@ORA9I.WORLD> select ename, dname
2 from emp left outer join dept on ( emp.deptno = dept.deptno OR emp.empno = 55 );

ENAME DNAME
---------- --------------
SMITH RESEARCH
....



ORA-01719 - in oracle 7i

Mahesh, May 09, 2005 - 2:07 am UTC

select * from forms, form_sql
where forms.form = 'GAM_PO'
or forms.form = 'EFF_CHECK'
and form_sql.form(+) = forms.form

how do I implement this in Oracle 7

Tom Kyte
May 09, 2005 - 7:01 am UTC

tkyte@DEV716> select *
2 from (select *
3 from forms
4 where form in ('GAM_PO','EFF_CHECK' ) ) forms,
5 form_sql
6 where form_sql.form(+) = forms.form
7 /

no rows selected


How to avoid

Martin van Donselaar, August 05, 2005 - 10:31 am UTC

This 'trick' on Eddie Awad's blog seems to work very well.

</code> http://awads.net/wp/2005/07/01/outer-joins-and-or/ <code>

A very nice blog in general, thanks for sharing that Tom :)



Tom Kyte
August 05, 2005 - 1:50 pm UTC

hmm, that material does look suspiciously familar.

Eddie Awad, August 05, 2005 - 3:25 pm UTC

Tom,
First, let me thank you for linking to my Oracle Docs Firefox search plugin from AskTom.oracle.com. I am a big fan. I have learned a lot from you.

Second, I would like to clarify that the origin of the material about how to overcome ORA-01719 is from this thread. That's why it looks familiar. I added a link back to this page from my blog.

Thank you again for sharing your legendary knowledge with the Oracle enthusiasts all around the world.

Tom Kyte
August 05, 2005 - 5:41 pm UTC

no worries, the link back is a good thing. I want the material propagated all over the place.

Difference in Tom's Suggestion and Oracle's Suggestion

Asim Naveed, October 13, 2005 - 3:11 am UTC

Referring to your earlier followup in this thread
"I can say in 9i, the restriction is removed:

scott@ORA9I.WORLD> select ename, dname
2 from emp left outer join dept on ( emp.deptno = dept.deptno OR emp.empno =
55 ); "

and then refering to Oracle documentation 9i Release 2.

ORA-01719
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)).

My question is, why doesnt oracle documentation suggest the
same as Tom's suggestion.

Does that mean Tom's suggestion may not work in some remote cases?

If ANSI Syntax is equivalent to that for which ORA-01719 appears, then shouldnt Oracle documentation suggest that
"USE the ansi syntax to acheive the same thing"




Tom Kyte
October 13, 2005 - 10:34 am UTC

because the documentation evolves over time - and this was an example from before left outer join that likely didn't get updated.



More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library