Return-Path: <root@fatcity.cts.com>
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by naude.co.za (8.11.2/8.11.2) with SMTP id g4TNwFS08846
 for <oracle-l@naude.co.za>; Wed, 29 May 2002 19:58:15 -0400
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id IAA05289;
 Wed, 29 May 2002 08:55:10 -0700 (PDT)
Received: by fatcity.com (26-Feb-2001/v1.0g-b71/bab) via UUCP id 0046E33E; Wed, 29 May 2002 07:18:32 -0800
Message-ID: <F001.0046E33E.20020529071832@fatcity.com>
Date: Wed, 29 May 2002 07:18:32 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Whittle Jerome Contr NCI" <Jerome.Whittle@scott.af.mil>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Whittle Jerome Contr NCI" <Jerome.Whittle@scott.af.mil>
Subject: RE: ora-918
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 71; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/alternative;	boundary="----_=_NextPart_001_01C20719.2A358928"
------_=_NextPart_001_01C20719.2A358928
Content-Type: text/plain;
 charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Yechiel,

"MONTH" is a reserved word in PL SQL and you have a field name "month". =
Could that be the problem?

Jerry Whittle
ACIFICS DBA
NCI Information Systems Inc.
jerome.whittle@scott.af.mil
618-622-4145

> -----Original Message-----
> From:	Yechiel Adar [SMTP:adar76@inter.net.il]
>=20
> Hello list
>=20
> I need help in solving ORA-918: Ambiguous field reference.
> All the fields are  schema.tablename.fieldname.
> The SQL has 3 inline queries that are the same but with different
> months in the where clause.
> Simplified version:
> select acct .....
> from tab1, tab2, ....
> where
> .......
> and acct in (select acct from tab1 where balance > 7000 and month =3D =
2)
> and acct in (select acct from tab1 where balance > 7000 and month =3D =
3)
> and acct in (select acct from tab1 where balance > 7000 and month =3D =
4)
> group by acct;
>=20
> Now the query runs OK with only one sub query.
> Oracle 8.1.6.3.4 on NT.
>=20
> I already replaced the three IN with 3 =3D select count() where month =
in
> (2,3,4)
> and it works, but I would like to know why the original didn't.
>=20
> Yechiel Adar
> Mehish
>=20

------_=_NextPart_001_01C20719.2A358928
Content-Type: text/html;
 charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>RE: ora-918</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">Yechiel,</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">&quot;MONTH&quot; is a reserved word in PL SQL and you =
have a field name &quot;month&quot;. Could that be the =
problem?</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT FACE=3D"Arial">Jerry Whittle</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT FACE=3D"Arial">ACIFICS DBA</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT FACE=3D"Arial">NCI Information Systems =
Inc.</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT =
FACE=3D"Arial">jerome.whittle@scott.af.mil</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT FACE=3D"Arial">618-622-4145</FONT></SPAN>
</P>
<UL>
<P><SPAN LANG=3D"en-us"><FONT SIZE=3D1 FACE=3D"Arial">-----Original =
Message-----</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><B><FONT SIZE=3D1 =
FACE=3D"Arial">From:&nbsp;&nbsp;</FONT></B> <FONT SIZE=3D1 =
FACE=3D"Arial">Yechiel Adar [SMTP:adar76@inter.net.il]</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Hello =
list</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">I need help in =
solving ORA-918: Ambiguous field reference.</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">All the fields =
are&nbsp; schema.tablename.fieldname.</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">The SQL has 3 =
inline queries that are the same but with different</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">months in the =
where clause.</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Simplified =
version:</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">select acct =
.....</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">from tab1, tab2, =
....</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">where</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">.......</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">and acct in =
(select acct from tab1 where balance &gt; 7000 and month =3D =
2)</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">and acct in =
(select acct from tab1 where balance &gt; 7000 and month =3D =
3)</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">and acct in =
(select acct from tab1 where balance &gt; 7000 and month =3D =
4)</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">group by =
acct;</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Now the query runs =
OK with only one sub query.</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Oracle 8.1.6.3.4 =
on NT.</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">I already replaced =
the three IN with 3 =3D select count() where month in</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">(2,3,4)</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">and it works, but =
I would like to know why the original didn't.</FONT></SPAN>
</P>

<P><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Yechiel =
Adar</FONT></SPAN>

<BR><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">Mehish</FONT></SPAN>
</P>
</UL>
</BODY>
</HTML>
------_=_NextPart_001_01C20719.2A358928--
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Whittle Jerome Contr NCI
  INET: Jerome.Whittle@scott.af.mil

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

