Strange behaviuor (bug?) with view (ora-918 column ambiguously defined)

Hallo everybody,
the following code works as expected;
select substr(fire_id,-4,2) as ct,zone_id, count(fire_id),sum(a_total) from
(select *
from fire right join fire_zone using (fire_id)
where definition_id = 1
and checked = 1
and substr(fire_id,-4,2) in (21,23)
and fire_id between 190400000000 and 200900000000)
group by substr(fire_id,-4,2),zone_id
order by ct, zone_id
but when a define a view for the subquery:
create or replace view tempfire as
select *
from fire right join fire_zone using (fire_id)
where definition_id = 1
and checked = 1
and substr(fire_id,-4,2) in (21,23)
and fire_id between 190400000000 and 200900000000
and then run
select substr(fire_id,-4,2) as ct,zone_id, count(fire_id),sum(a_total) from tempfire
group by substr(fire_id,-4,2),zone_id
order by ct, zone_id
I got the error ora-00918 column ambiguously defined for zone_id.
Is this a bug or is there a reason?
Thank you in advance,
Cheers,
Boris
Edited by: boris on Nov 19, 2009 6:49 AM
Edited by: boris on Nov 19, 2009 6:52 AM

user503699
I followed your suggestion and now it works. Thank you !
But something is strange ... this is the result of the desc tempfire ... and all the column names are different ...
desc tempfire
Name Null Type
FIRE_ID NOT NULL NUMBER(12)
START_DATE DATE
END_DATE DATE
LOCALITY VARCHAR2(56)
X_COORD NUMBER(6)
Y_COORD NUMBER(6)
COORD_RELIABILITY_ID NUMBER(1)
ALTITUDE NUMBER(4)
SITE_ID NUMBER(1)
EXPO_ID NUMBER(1)
SLOPE NUMBER(3)
X_BUSH NUMBER(1)
X_COPPICE NUMBER(1)
X_COPPICE_MIXED NUMBER(1)
X_SELVA NUMBER(1)
X_HIGH_FOREST_HARDWOOD NUMBER(1)
X_HIGH_FOREST_SOFTWOOD NUMBER(1)
X_HIGH_FOREST_MIXED NUMBER(1)
X_PIONEER NUMBER(1)
X_FORESTATION NUMBER(1)
S_BUSH NUMBER(8,2)
S_COPPICE NUMBER(8,2)
S_COPPICE_MIXED NUMBER(8,2)
S_SELVA NUMBER(8,2)
S_HIGH_FOREST_HARDWOOD NUMBER(8,2)
S_HIGH_FOREST_SOFTWOOD NUMBER(8,2)
S_HIGH_FOREST_MIXED NUMBER(8,2)
S_PIONEER NUMBER(8,2)
S_FORESTATION NUMBER(8,2)
A_FOREST NUMBER(8,2)
A_GRASSLAND NUMBER(8,2)
A_NONPRODUCTIVE NUMBER(8,2)
A_TOTAL NUMBER(8,2)
D_CASTANEA NUMBER(1)
D_QUERCUS NUMBER(1)
D_FAGUS NUMBER(1)
D_BETULA NUMBER(1)
D_OTHER_HARDWOOD NUMBER(1)
D_PINUS NUMBER(1)
D_PICEA NUMBER(1)
D_LARIX NUMBER(1)
D_OTHER_SOFTWOOD NUMBER(1)
DIAMETER NUMBER(3)
LITTER_ID NUMBER(1)
HERB_LAYER_ID NUMBER(1)
BUSH_LAYER_ID NUMBER(1)
FIRE_SURFACE NUMBER(1)
FIRE_CROWN NUMBER(1)
FIRE_SINGLE_TREE NUMBER(1)
FIRE_SUBSURFACE NUMBER(1)
DAMAGE_FOREST_ID NUMBER(1)
DAMAGE_SOIL_ID NUMBER(1)
HEIGHT_DAMAGE NUMBER(4,2)
F_PROTECTION NUMBER(1)
F_ECONOMIC NUMBER(1)
F_RECREATION NUMBER(1)
CAUSE_ID NUMBER(2)
OTHER_CAUSE VARCHAR2(200)
CAUSE_RELIABILITY_ID NUMBER(1)
ALARM_FORESTDEP DATE
CHECKED NUMBER(1)
DATA_FROM_FORESTDEP NUMBER(1)
DATA_FROM_FIREMANDEP NUMBER(1)
DATA_FROM_HISTORY NUMBER(1)
INSERT_DATE DATE
INSERT_BY VARCHAR2(16)
UPDATE_DATE DATE
UPDATE_BY VARCHAR2(16)
OLD_TI_AFFDFO VARCHAR2(1)
OLD_TI_S_SPES NUMBER(8,2)
OLD_TI_PICFOR VARCHAR2(1)
OLD_TI_FIRE_TYPE VARCHAR2(1)
OLD_TI_DOMINANT_SPECIES VARCHAR2(1)
OLD_TI_CAUSE VARCHAR2(2)
OLD_TI_FOREST_TYPE VARCHAR2(1)
START_DATE_RELIABILITY_ID NUMBER(1)
END_DATE_RELIABILITY_ID NUMBER(1)
DEFINITION_ID NUMBER(1)
ZONE_ID NOT NULL NUMBER(8)
79 rows selected
I'm still interested hoe to use hints. Can anybody tell me?
Thank you
Boris

Similar Messages

  • ORA-00918: column ambiguously defined : while using inner Select

    Hi
    could you please help me to solve the following from.
    I have a query like this
    SELECT * FROM (SELECT ZMV.VENDOR_NAME,FR.PO_NUM,ZMV.PART_NUMBER,FR.ZAC_ITEM_DESCRIPTION,ZMV.QUANTITY_ORDERED,FR.QUANTITY_RECEIVED,ZMV.PO_UOM_CODE,FR.VENDOR_INV,FR.FORWARDER_REF,FR.PCS,TY.DESCRIPTION,FR.GROSS_WGT,FR.NET_WGT,FR.CFT,TR.DESCRIPTION,FR.PRO,FR.FORWARDER_REMARK,FR.RECAP_ID,FR.ZAC_REMARK,FR.SHIPMENT_BY FROM FWD_RECAP FR,ZAC_METRO_VIEW ZMV,FWD_MASTER_TYPE TY,FWD_MASTER_TRUCK TR WHERE FR.TYPE_ID=TY.TYPE_ID AND FR.TRUCK_ID=TR.TRUCK_ID AND FR.PO_LINE_ID=ZMV.PO_LINE_ID AND FR.PACKAGE_ID=0 AND FR.OPERATIONING_UINT_ID=511 AND FR.FORWARDER='METRO,ITALY' ORDER BY FR.PO_LINE_ID DESC) WHERE ROWNUM <=10
    But while executing the following error showing,
    SELECT * FROM (SELECT ZMV.VENDOR_NAME,FR.PO_NUM,ZMV.PART_NUMBER,FR.ZAC_ITEM_DESCRIPTION,ZMV.QUANTIT
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    For this problem i got some answers from web sites, they saying as follows, but i am using like that only.
    (ORA-00918: COLUMN AMBIGUOUSLY DEFINED)
    Use table aliases and prefix all column names by their aliases when more than one table is involved in a query. This reduces parse time AND prevents future syntax errors if someone adds a column to one of the tables with the same name as a column in another table.
    awaiting your immediate reply
    Thankyou
    Jobin [[email protected]]

    In your inline view you have fields
    TY.DESCRIPTION and TR.DESCRIPTION which are the same
    name DESCRIPTION for covered SQL.
    place TY.DESCRIPTION TY_DESCRIPTION and
    TR.DESCRIPTION TR_DESCRIPTION in your code:
    SELECT * FROM (SELECT ZMV.VENDOR_NAME,FR.PO_NUM,ZMV.PART_NUMBER,FR.ZAC_ITEM_DESCRIPTION,ZMV.QUANTITY_ORDERED,FR.QUANTITY_RECEIVED,ZMV.PO_UOM_CODE,FR.VENDOR_INV,FR.FORWARDER_REF,FR.PCS,TY.DESCRIPTION TY_DESCRIPTION ,FR.GROSS_WGT,FR.NET_WGT,FR.CFT,TR.DESCRIPTION TR_DESCRIPTION,FR.PRO,FR.FORWARDER_REMARK,FR.RECAP_ID,FR.ZAC_REMARK,FR.SHIPMENT_BY FROM FWD_RECAP FR,ZAC_METRO_VIEW ZMV,FWD_MASTER_TYPE TY,FWD_MASTER_TRUCK TR WHERE FR.TYPE_ID=TY.TYPE_ID AND FR.TRUCK_ID=TR.TRUCK_ID AND FR.PO_LINE_ID=ZMV.PO_LINE_ID AND FR.PACKAGE_ID=0 AND FR.OPERATIONING_UINT_ID=511 AND FR.FORWARDER='METRO,ITALY' ORDER BY FR.PO_LINE_ID DESC) WHERE ROWNUM <=10
    Rgds

  • How to get rid of ROWID in Join query -- ORA-00918: column ambiguously defined

    Hi, All
    the source of my data block is from two tables Emp and Title. My select statements is:
    select a.name, b.title, b.start_date, b.end_date from Emp a, Title b where a.id = b.emp_id
    But at run time, I got "ORA-00918: column ambiguously defined"
    the wrapped statement becomes:
    SELECT ROWID,a.name, b.title, b.start_date, b.end_date from Emp a, Title b where a.id = b.emp_id
    I run the query in SQL*PLUS, found out it was ROWID caused problem.
    Can anybody tell me how to get rid of ROWID? or I missed something in datablock defination?
    Thanks in adance.
    Deborah

    I guess you are using oracle 7.x. In Oracle 8 and onwards, database lets you select ROWID from the views based on multiple views as long as view definition does not contain any aggregated functions or DISTINCT in it. Now coming back to forms ..Forms runtime engine uses ROWID to identify rows uniquely unless specified otherwise. If you are using forms 4.5/5.0 against Oracle 7.x , then change these properties and you should be able to run the form.
    BLOCK PROPERTY
    Key Mode : can be either updateable OR Non-updateable
    ( Certainly not 'Unique' .. That forces forms runtime engine to use ROWID to identify unique rows. )
    ITEM PROPERTY
    Identify one of the block items as unique. And then set the following property
    Primary Key : True.
    This should take care of rowid problem.
    Regards,
    Murali.
    Hi, All
    the source of my data block is from two tables Emp and Title. My select statements is:
    select a.name, b.title, b.start_date, b.end_date from Emp a, Title b where a.id = b.emp_id
    But at run time, I got "ORA-00918: column ambiguously defined"
    the wrapped statement becomes:
    SELECT ROWID,a.name, b.title, b.start_date, b.end_date from Emp a, Title b where a.id = b.emp_id
    I run the query in SQL*PLUS, found out it was ROWID caused problem.
    Can anybody tell me how to get rid of ROWID? or I missed something in datablock defination?
    Thanks in adance.
    Deborah

  • Eclipselink producing incorrect sql - ORA-00918: column ambiguously defined

    We have a table with many columns .A1 .A2 .A3.... .A125 .N1 .N2 .N3... .N95 and with a simple jpql join it comes up with 2 columns that are ...AS N1150 and causing an ambiguous column error ...
    Does any one know of a valid workround or if this is a known bug. No problems were present in toplink, just eclipselink....
    it appears to be doing a count and suffixing the count to the column name to make sure the columns have unique id's - but failing:
    K1 -> K1 _1_
    N41 -> N41 _2_
    N11 -> N11 _50_
    ... then 100 columns later
    N1 -> N1 _150_
    the jpql is :
    @NamedQuery(name=NamedQueryNames.XREF_IMPORT_SELECT,
                   query="SELECT t FROM Tran t, Xref x "+
                   " WHERE t.key = x.a1 "+
                   " AND x.key.k1 = :partial "+
                   " AND x.key.k2 LIKE :partialX " +
                   " ORDER BY x.key.k2")
    Tran has fields k1,k2, a1, a2...a125, n1, n2...n95
    xref has k1,k2,a1,a2..a5, n1,n2,n3
    the sql eclipse link produces for the query is :
    SELECT *
    FROM
    (SELECT
    /*+ FIRSTROWS */
    a.*,
    ROWNUM rnum
    FROM
    (SELECT t1.K1 AS K11,
    t1.N41 AS N412,
    t1.N40 AS N403,
    t1.N45 AS N454,
    t1.N44 AS N445,
    t1.A120 AS A1206,
    t1.N43 AS N437,
    t1.A121 AS A1218,
    t1.N42 AS N429,
    etc
    t1.N25 AS N2547,
    t1.N10 AS N1048,
    t1.N12 AS N1249,
    t1.N11 AS N1150,
    t1.N17 AS N1751,
    a load more columns
    t1.A65 AS A65147,
    t1.A68 AS A68148,
    t1.A67 AS A67149,
    t1.N1 AS N1150,
    t1.A41 AS A41151,
    t1.N5 AS N5152,
    etc
    FROM COREXFA t0,
    CORETRA t1
    WHERE (((t1.K1 = t0.A1)
    AND (t0.K1 = ?))
    AND (t0.K2 LIKE ?))
    ORDER BY t0.K2 ASC
    ) a
    WHERE ROWNUM <= ?
    WHERE rnum > ?

    This issue is cause by the aliasing done because you are using firstResult/maxResult. I think there is already a bug logged for this issue, please vote for the bug.
    See,
    http://old.nabble.com/Duplicate-aliases-generated-for-columns-%281.1.3%29-td28039552.html
    Some workarounds would be,
    - avoid using firstResult/maxResult
    - rename the columns
    - use native SQL
    - use a cursor query instead of firstResult/maxResult
    James : http://www.eclipselink.org

  • 'column ambiguously defined' due to automatic addition of rowid to every JDBC calls

    We are using Weblogic 6.0 spf 1 and Oracle as back end.
    When ever we fire an SQL using JDBC, Weblogic automatically adds 'rowid' to the
    select clause and fires the SQL. If Oralce returns the error 'ORA-00918: column
    ambiguously defined', the rowid is removed and the SQL is run as requested.
    For example, when we say -
    SELECT *
    FROM SOME_TABLE
    Rowid is added blindly and executed query will be
    SELECT rowid, *
    FROM SOME_TABLE
    Oracle throws 'Column Ambigiously defined'. Upon this error weblogic fires originally
    requested query
    SELECT *
    FROM SOME_TABLE
    Another condition where it always fails is in case of SQL joins.
    Is there any way to avoid adding rowid to the SQL statments?
    Thanks
    Satish

    I would appreciate an answer to this same question: "Can the automatic addition of rowid after the select be prevented"? as it is causing several index hints to be rejected.

  • Version Change from 10.2.0.3.0 to 11.2.0.4.0 - Column ambiguously defined

    Hi,
    Our oracle version has been upgraded from 10g to 11g.
    After upgrade we face serious problem in compiling several packages, procedures and views and that throws an error "Column Ambiguously Defined", which was running perfectly in 10g version.
    I have come through several blogs like, this problem occurs for many ppl as part of upgrade from 10g to 11g and the only solution is to change the code.
    But in our case we have many numbers of objects like procedures, packages and views where this error occurs, do we have any common solution for overcome this problem (without changing the code)?
    Regards,
    Ananth

    e7a47215-0e59-4d88-a082-7ad5e83ce5b0 wrote:
    Hi,
    Our oracle version has been upgraded from 10g to 11g.
    After upgrade we face serious problem in compiling several packages, procedures and views and that throws an error "Column Ambiguously Defined", which was running perfectly in 10g version.
    I have come through several blogs like, this problem occurs for many ppl as part of upgrade from 10g to 11g and the only solution is to change the code.
    But in our case we have many numbers of objects like procedures, packages and views where this error occurs, do we have any common solution for overcome this problem (without changing the code)?
    Regards,
    Ananth
    You will need to bite the bullet & change the code

  • Column ambiguously defined

    select distinct hp.SYER_PEMBILANG||'/'||hp.SYER_PEMBILANG semua, kp.NAMA kod_pihak_nama,
    kb.nama kod_bpm_nama,
    kd.NAMA kod_daerah_nama,
    kl.NAMA kod_lot_nama,
    mo.ID_MOHON ,
    ha.NO_LOT,
    ha.KOD_HAKMILIK,
    ha.NO_HAKMILIK
    kd.NAMA kod_daerah_nama
    from
    mohon mo,
    mohon_pihak mp join kod_pihak kp on (mp.kod_pihak=kp.kod),
    hakmilik ha join kod_bpm kb on(ha.kod_bpm=kb.kod)
    join kod_daerah kd on(ha.kod_daerah=kd.kod)
    join kod_lot kl on (ha.KOD_LOT=kl.kod),
    mohon mo join kod_caw kc on(mo.kod_caw=kc.kod),
    kod_caw kc join kod_daerah kd on(kc.kod_daerah=kd.kod),
    mohon_hakmilik mh,
    hakmilik_pihak hp
    where
    mp.KOD_PIHAK ='PG'
    and mo.KOD_CAW=kc.KOD
    and kc.KOD_DAERAH=kd.kod
    and mo.id_mohon=:p_id_mohon
    and ha.KOD_BPM=kb.KOD
    and ha.KOD_DAERAH=kd.KOD
    and ha.KOD_LOT=kl.KOD
    and mo.ID_MOHON=mh.ID_MOHON
    and mh.id_hakmilik=ha.ID_HAKMILIK
    and mo.ID_MOHON=mp.ID_MOHON
    and mp.KOD_PIHAK=kp.KOD
    and hp.ID_HAKMILIK=ha.ID_HAKMILIKcolumn ambiguously defined
    Edited by: user9093689 on Nov 8, 2010 12:55 AM

    Is nobody going for the "new" syntax?
    I belive this makes the relationship between tables so much more visible (and a LEFT to mohon would be not possible with "old" JOIN.
    SELECT
      DISTINCT hp.SYER_PEMBILANG||'/'||hp.SYER_PEMBILANG semua, kp.NAMA kod_pihak_nama,
      kb.nama        kod_bpm_nama,
      kd.nama        kod_daerah_nama,
      kl.nama        kod_lot_nama,
      mo.id_mohon ,
      ha.no_lot,
      ha.kod_hakmilik,
      ha.no_hakmilik
      kd.nama kod_daerah_nama
    FROM mohon_pihak mp
    INNER JOIN kod_pihak kp
    ON (mp.kod_pihak=kp.kod)
    INNER JOIN kod_bpm kb
    ON(ha.kod_bpm=kb.kod)
    INNER JOIN kod_lot kl
    ON (ha.KOD_LOT=kl.kod)
    -- twice INNER join kod_daerah kd
    INNER JOIN hakmilik ha
    on (   ha.KOD_BPM=kb.KOD
       AND ha.kod_daerah=kd.kod
       AND ha.KOD_DAERAH=kd.KOD
       AND ha.KOD_LOT=kl.KOD)
    -- twice INNER JOIN mohon mo
    INNER join kod_caw kc
    ON(mo.kod_caw=kc.kod)
    -- twice INNER JOIN kod_caw kc
    INNER join kod_daerah kd
    ON(kc.kod_daerah=kd.kod)
    INNER JOIN mohon_hakmilik mh
    ON (mh.id_hakmilik=ha.id_hakmilik)
    INNER JOIN hakmilik_pihak hp
    ON hp.id_hakmilik=ha.id_hakmilik
    INNER JOIN mohon mo
    ON  (  mo.ID_MOHON= mh.ID_MOHON
        AND mo.KOD_CAW = kc.KOD
        AND mo.ID_MOHON=mp.ID_MOHON)
    WHERE
         mp.KOD_PIHAK ='PG'
    AND  mo.id_mohon=:p_id_mohon
    ;--andy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • IPhone SDK 6 : Bug with VIew controller Autorotation ?

    Since i installed the Beta 6, the views that used to work fine now dont size properly after the orientation has been changed. For e.g. when i change the orientation the size of the view changes to 560 x 240. It should have been 480 x 320.
    I should note here that i am not using the IB. I code my views and view controllers.
    Am i missing something? Has anyone noticed a similar behavior?
    Thanks.
    -TRS

    The issue is with UINavigationController navigationBarHidden property being set to YES. The view sizes properly after rotation if this property is set to NO which is the default.
    This issue may be fixed in Beta 7 but i have not had a chance to verify it. Will test and post my results here.
    I have filed a bug after an apple engineer at WWDC confirmed it is a bug.
    -TRS

  • Strange HTT bugs with Neo4/Platinum SLI on Athlon64 .09 Winchester Core

    Hey..
    I am setting up my new Neo4, and I've run into some very strange non-overclocked behaviour with the AMD64 Winchester core CPU. This does not happen with my Clawhammer CPU on the Neo4, and it also doesn't happen with the same Winchester CPU on two other different nForce4 boards I've tried. So it appears to be a problem with this MSI Neo4 board only.
    When I run default non-overclocked settings of 5x HTT at 200mhz, I get a readout of 800mhz HyperTransport in Central-Brain Identifier.. what!?!
    I have tried changing to various other HTT values and it's all whacked out and random... For example:
    If I set the HTT to 2x, in Central Brain Identifier, it's showing as 4x HTT..
    And if I set 1x HTT at 250mhz, Central Brain shows HTT at 1000 mhz??
    Also.. when I check the HTT speed in other software, like Sandra... it is reporting conflicting Hypertransport speeds.. Each of the softwares is reporting something different. The HTT is all freaked out on Neo4+Winchester core. What is going on?
    This isn't happening on any other nForce4 boards with the same software and CPU.
    This Winchester core CPU is running at 1000mhz HTT on two other nForce4 boards I've tried.
    I have no idea what the HTT is truely even running a now, cause of such bugginess with this Neo4.
    Apparently Neo4 has problems with Winchester core even at stock settings.
    Why no word from MSI on this? Will MSI ever fix their problem with Winchesters that no other boards have.. Or will they cause more enthusiasts to lose faith and not buy MSI in the future? Does MSI even care?
    ...Omnihil

    Tiresmoke no offence but ur a moderator of this forum.  Whats stopping moderators reporting problems that users innocure due to the products MSI produce ? Your a moderator and a moderator should acctually be able to report the big problems with MSI.  I'm not gettin on your back but when people start threads off about stuff thats wrong then we have the right to know... ill contact MSI about it now to see what they say and im sure they would come visit the forum if they new their product had faults....
    Quote
    This Forum is a User-to-User support community for users of all ages. There is no MSI support to be found here. The moderators are not paid by MSI and do not work for MSI, we are users just like you.
    Quote
    So how did you become a moderator and why ?  If your just a user then why be a moderator ?????

  • Strange thing noticed with a view and group by

    Hi all, Could anybody please tell me what could be the problem if you have come across it ever.
    I am using a view which is fetching 4 million rows from another db thru a dblink. In the view query this data is joined with two other small temporary tables and the output is taken out.
    The whole process is like this...
    1.Create the two temporary tables..
    2. Alter the view to compile;( as these temporary tables are dropped after the whole process)
    3. insert into the target table using another query by taking the data from the VIEW
    4. drop the temporary tables.
    All these are in a single script.
    In the insert statement I use a group by in the select statement to produce sum of three columns.
    the ideal output is as giiven below:
    total rows= 4.7 million.
    after the group by i should get 293,356 rows( i tested it after taking all the rows from the view into my db and did a group by on it with the required columns)
    Now the group by is done directly by taking the data from the view and inserting into the final table.
    When i ran the script for the first time I got this 293,356 rows... The second time I ran it gave me only 73090 rows. But the sum total of those 3 columns are exctly same as that of 293,356 rows. I donot change the number of columns in group by or anything like that... what i am doing is just running it again....
    Can anybody tell me why it gives different number of rows at different times when the same script is run without any changes...( There is no difference in the original number of rows too..)
    Thanks
    Edited by: user626688 on Oct 17, 2008 12:26 PM

    Way not enough information.
    Assume you have Oracle to Oracle connection here (with your DB link). What version are BOTH databases on. No idea what the view looks like, or how you use it, or what these 'temporary tables' you create on the fly do.
    Can you put together a small example of this which recreates your problem? We don't have your tables, your script, your ability to run queries and check things, so there's really not much anyone can do to help you with this.
    The simplest explanation is usually the correct one, so although it's possible you've hit an internal Oracle bug, i'd put my money in there being a flaw in your processing, it's where the safe money is. Though there could be a bug with view merging, or the DB link, or .....

  • Oracle 11g bug for column ambigously defined error

    I have below format query running on Oracle 10g without any issues
    select col1
    from (select col1
    from (select 'A' col1
    from dual)
    ) v1
    inner join (select col1 as col2
    from (select 'A' col1
    from dual)
    ) v2
    on (v1.col1=v2.col2);
    When I run the exact same query on Oracle 11g I get column ambiguously defined error. But when I change the query to as below it works fine on 11g
    select v1.col1
    from (select col1
    from (select 'A' col1
    from dual)
    ) v1
    inner join (select col1 as col2
    from (select 'A' col1
    from dual)
    ) v2
    on (v1.col1=v2.col2);
    Is it because 11g ignores column alias in my inner queries.

    I'd tend to agree that this seems to be a bug in 11.1.0.7 (at least, that's the version I'm running it in)
    It's not even that Oracle doesn't know about the column aliases, you can remove the aliases in the ON without a problem, i.e.
    SELECT v1.col1
       FROM
      (SELECT col1 FROM
        (SELECT 'A' col1 FROM dual
      ) v1
    INNER JOIN
      (SELECT col1 AS col2 FROM
        (SELECT 'A' col1 FROM dual
      ) v2
         ON (col1=col2);works fine. Using the old join syntax also seems to work fine
    SELECT col1
       FROM
      (SELECT col1 FROM
        (SELECT 'A' col1 FROM dual
      ) v1,
      (SELECT col1 AS col2 FROM
        (SELECT 'A' col1 FROM dual
      ) v2
      WHERE (col1=col2);So it appears that something in the SQL 99 parser is broken. Have you logged a bug in Metalink?
    Justin

  • "column ambigously defined" error

    ORA-00918: column ambigously defined
    00918.00000 - "column ambigously defined"
    *Cause:
    *Action
    Vendor code 918     
    I've gotten this error on a few of the queries I've ran in SQL Developer 1.5 and tried to export to xls, but when I run and try to export the same query in 1.2.1 it's fine. There is another popup box that provides this detail (below). What causes this error and how can it be fixed?
    java.lang.NullPointerException
         at oracle.dbtools.raptor.dialogs.export.ColumnPanel.addColumnsToTree(ColumnPanel.java:85)
         at oracle.dbtools.raptor.dialogs.export.ColumnPanel.showPanel(ColumnPanel.java:61)
         at oracle.dbtools.raptor.dialogs.export.ColumnPanel.<init>(ColumnPanel.java:50)
         at oracle.dbtools.raptor.dialogs.actions.TableExportAction.showPanels(TableExportAction.java:291)
         at oracle.dbtools.raptor.dialogs.actions.TableExportAction.launchDlg(TableExportAction.java:189)
         at oracle.dbtools.raptor.format.ui.ExportContextMenuListener$1.actionPerformed(ExportContextMenuListener.java:137)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
         at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
         at java.awt.Component.processMouseEvent(Component.java:5488)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
         at java.awt.Component.processEvent(Component.java:5253)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3955)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    The problem is that SQL Developer 1.5.0/1 generates and executes a query that is not quite your original query to assist with the export dialog (presumably to populate the Columns tab). Note that it also does a single bulk fetch against this query, which can cause performance issues when trying to export the results of long running queries.
    For the example query of:
    select t.id, t2.id from t,t2;
    this generated query is:
    select * from ( select "ID","ID" from ( select t.id, t2.id from t,t2 ) )
    The export works in 1.2.1 simply because they did not generate this additional query, but re-executed the original query.
    theFurryOne

  • ICal bug with month view

    I primarily use week view on iCal, but sometimes i switch to month view for a larger perspective. Often, i use month view to check for any leftover events from the previous month in case i forgot to delete one or two.
    I just found a bug concerning this. If i click on "month" today, it'll take me to the month view for june 2011, and from there i can navigate forwards or backwards. However, may 2011 seems to have a bug. If i click on < from june, it does nothing; if i click again, it takes me to april 2011. Similarly, if i click on > from april it does nothing and if i click again it takes me to june.
    It doesn't end there. The june/may thing happens only when the selected day (the one shaded light grey on the month and week views and bright blue on the little month tab on the left) is after 04 june. If a day from the first week of june (i have my weeks start on sunday) is selected, the < button does take me to may, but several events which i deleted a long time ago are showing up.
    Now, i have an event set for today (04 june). Since the first four days of june are in the same week as the last three of may, the month view for may shows these four days, as any normal calendar app would.
    If i use the month tab to the left to navigate, i can access may 2011 by selecting any day on that month. However, iCal's behaviour depends on which day was selected previously. If the previous day was in april 2011 or earlier, iCal will show the month of may completely empty, which is great because i have no leftover appointments from may; however, the box for 04 june is also empty, which it shouldn't be. If the previous day was in june 2011, it'll show may with a repeating event on every sunday except the first, which is completely absurd, since i have deleted this event (and why isn't it showing on the first sunday in may?); the box for 04 june, however, will correctly show the event i have set for this day. If the previous day was in july 2011 or later, it'll show may with the repeating event on all sundays (including the first one) and it won't show anything on the box for 04 june.
    Obviously, there is a bug with may 2011.
    In case it helps, i do have a repeating event set to all sundays until the end of existence, but i have deleted all the entries from may and previously, since they have obviously already happened. Also, i had many other repeating events set to happen on different weekdays; these are to repeat themselves weekly until about halfway through june, and they started on april or may (can't remember right now). Like the sunday one, i have deleted all the entries from may because they have already taken place. Strangely (and thankfully), none of these appear when i visit may from june or later, as does the sunday event.
    Any help would be greatly appreciated. Or am i forever stuck with week view, which has so far proven to be bug-free?
    (I did a search on Google and another on the Apple forums for this issue but could find nothing, so i decided to ask the question myself. I apologise if somebody has already asked this question and i just couldn't find it.)

    Greetings,
    I have a vague recollection of someone else with this issue but haven't experienced it myself nor encountered it recently.
    Troubleshooting:
    1.) First make an iCal backup: http://support.apple.com/kb/HT2966.
    2.) Remove the following to the trash and restart your computer:
    Home > Library > Caches > com.apple.ical and / or "ical"
    Home > Library > Calendars > Calendar Cache, Cache, Cache 1, 2, 3, etc. (Do not remove Sync Cache or Theme Cache)
    Home > Library > Preferences > com.apple.ical (There may be more than one of these. Remove them all.)
    __NOTE: Removing these files will remove any shared (CalDAV) calendars you may have access to. You will have to re-add those calendars to iCal > Preferences > Accounts.
    Once the computer is back up and running open iCal and test.
    Hope that helps!

  • DB view with flexible number of columns?

    In my Oracle 10 I have these tables
    Customer table:
    id      customer
    1       John
    2       Bob
    Item table
    id      item_name
    1       itemA
    2       itemB
    3       itemC
    4       itemD
    Purchase table:
    id      item_id date    customer_id
    1       3       070202  2
    2       6       070203  5
    ...I'd like to create a view like this:
            itemA   itemB   itemC   itemD   ...
    John    3       4       0       0       ...
    Bob     0       3       0       0       ...
    ...The view showed John purchased itemA 3 times, item B 4 times. Bob purchased itemB 3 times. This assume each customer only by one item at a time, which is a reasonable simplification of my situation.
    Such a view (with variable number of columns) is needed not in our web application but also provide an understandable data source for non IT professional to use report software. If my approach of solving this problem is completely wrong, I'd also like to know what's the common practice. Thank you very much in advance!
    Message was edited by:
    user609663

    I have tried to ask the question in a way that greatly simplify current problem to make it easy for others to understand without having to explain a lot of background information and 'the situation'; it seems I over-simplified the issue to make it even not worth solving or a wrong question being asked. So here I explain the complete problem and look for advice again (be prepared, pretty long description following:). I am a purchased customer of Oracle 10 DB and I reasonably expect being considered as Oracle user looking for help rather than students trying to play smart with assigned data normalization course exercises.
    We are working on a system that collects data from interview results. The questionnaires for the interviews are formatted with a coded question, followed by user's answer to the question, like the following:
         Question Code   Question content   Answer
         H001            ...                123
         H002            ...                45
         H003            ...                33
         H004            ...                66
         H005            ...                4,66
         ...             ...                ...The users answer question with a digit, for some special questions, e.g. H005, they are allowed to answer with a set of digits. There are thousands of interviews each year, the simplest solution to collect the interview answers is to use such a db table:
    simple_db_table:
    id   H001  H002  H003  H004  H005  H006  H007
    1    123   45    33    66    4     82    9
    ...This solution have two problems:
    1. It doesn't properly store answers to questions that requre a set of digits, like H005.
    2. The number of questions and their codes change from one survey to another, but the table have fixed number of columns and column names.
    And two benefit:
    1. With such simple table, people who use report software that directly access oracle db can creat their reports on easy-to-understand data presentation;
    2. calculation based on questionnaire data is simple, e.g. get the average of H007/H009 for questionnaires that have H002 > H003 * 600 would be:
    SELECT SUM(H007) / SUM(H009) FROM simple_db_table WHERE H002 > H003 * 600;Next solution we have normalized tables:
    questionnaire_entry_table:
    id                 NUMBER
    questionnaire_name CHARquestionnaire_definition_table:
    id                 NUMBER
    questionnaire_id   NUMBER
    question_code      CHAR
    question_content   VARHCARinterview_table:
    id                 NUMBER
    questionnaire_id   NUMBER
    date               DATEquestionnaire data table: itv_data
    id                 NUMBER
    interview_id       NUMBER
    question_code      CHAR
    answer             NUMBERWith the new structure, it just turn the problems of simple_db_table to its benefit and simple_db_table's benefit become the problem:
    1. Personnel who use report creation software feel too confused to make report based on such tables, because they do not understand the normalized modeling. In our case, effective training is difficult because there will be many geographically distributed people make reports based on this structure and they have lower IT knowledge than database administrators. These personnel can make reports based on simple_db_table.
    2. calculation based on questionnaire data is very difficult.
    To explain 2, let's take the same example, we still wish to get the average of H007/H009 for questionnaires that have H002 > H003 * 600, my method is:
    setp 1: create a view with by using:
           CREATE VIEW v (id, H002, H003) AS
           SELECT a.itv_id, a.H002, b.H003
             FROM itv_data a, itv_data b
           WHERE a.interviewee_id=b.interviewee_id
             AND a.question_code='H002' AND b.question_code='H003';step 2: create a stored procedure to get the calculation result:
           CREATE OR REPLACE PROCEDURE get_result (result OUT NUMBER) IS
             sh007 NUMBER := 0;
             sh009 NUMBER := 0;
           BEGIN
             SELECT SUM(H007) INTO sh007 FROM itv_data
               WHERE itv_id in (SELECT id FROM v WHERE H002 > H003 * 683);
             SELECT SUM(H009) INTO sh009 FROM itv_data
               WHERE itv_id in (SELECT id FROM v WHERE H002 > H003 * 683);
             idc := sh007/sh009;
           END get_idc;As you can see the calculation become much more complex and might involve overhead.
    There might be better way to calculate the result that I don't know yet. We have some 100 different formulas to calculate different results, so it's important to get them right and efficiently.
    The best solution seems to me is that to create such a view from itv_data and other tables so that to reflect the same structure of simple_db_table. So here comes the question I originally asked how is it possible to create a view with flexible number of columns. I made the very simple example in my original posted message wishing to get an idea of this is possible or the way to go.
    I may be taking a completely wrong approach to attack the problem, e.g. perhaps there is a simpler way to get_result from itv_table and for report creation users I should use a metadata layer on top of the normalized table structure (e.g. by using Metadata Query Language from Pentaho BI). But anyway I'd like to get some insightful ideas from the forum. Again thanks for help in advance.

  • Very strange bug with compareTo: returning incorrect results

    Hello everyone! I have used the method compareTo many times to maintain my database project's entries. However recently I have discovered a bug, in which:
    a and b both being Storage type objects:
    private static class Storage {
    object data
    int nextData //an array stores the Storage objects
    int previousData //this uses an integer to locate previous in array
    Problem:
    ((Comparable)(a.data)).compareTo((Comparable)(b.data)) returns a 3, when a.data is clearly 5, and b.data is clearly 20.
    This is very strange, as the compareTo should return a -1 instead of a positive number. Is this a known bug with the compareTo method? I have been using it reliably for many programs but this is the first time it ever occurs to me.

    Problem:
    ((Comparable)(a.data)).compareTo((Comparable)(b.data))
    returns a 3, when a.data is clearly 5, and b.data is
    clearly 20.
    This is very strange, as the compareTo should return a
    -1 instead of a positive number. Is this a known bug
    with the compareTo method? I have been using it
    reliably for many programs but this is the first time
    it ever occurs to me.Not really... comparing Strings "5" to "20"
    is really the same as comparing "5" to "2"
    being the first character of the string, difference
    being, surprise, surprise = 3.
    If you want the Strings to be comparable that way you should left-fill them with spaces or zeros.
    Or, better still, override compareTo and make your Storage implement Comparable instead of all that casting of the data objects.

Maybe you are looking for