Ambiguous Column ORA-00918

Hi,
Why does this work
select
dummy
from dual d1
join dual d2 on (d1.dummy = d2.dummy)
join dual d3 on (d1.dummy = d3.dummy)
join dual d4 on (d1.dummy = d4.dummy)
where
dummy = 'X'
and this doesn't
select
dummy
from dual d1
join dual d2 on (d1.dummy = d2.dummy)
--join dual d3  on (d1.dummy = d3.dummy)
where
dummy = 'X'
Many thanks
Nigel

Dunno. It's a good one, if only there was some kind of bounty for finding them. But it is just the twoofer that works, it's broken for however many more tables we add ...
SQL> select
  2  dummy
  3  from dual d1
  4  join dual d2 on (d1.dummy = d2.dummy);
dummy
ERROR at line 2:
ORA-00918: column ambiguously defined
SQL> select
  2  dummy
  3  from dual d1
  4  join dual d2 on (d1.dummy = d2.dummy)
  5  join dual d3 on (d1.dummy = d3.dummy)
  6  join dual d4 on (d1.dummy = d4.dummy)
  7  join dual d5 on (d1.dummy = d5.dummy)
  8  /
D
X
SQL> Cheers, APC

Similar Messages

  • 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

  • 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

  • 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

  • Getting EQP-80407 & ORA-00918 error in SES query

    Hi,
    We are using SES to implement Third party search and created a new data source of type "Database" to crawl the external db. when we start the scheduler to crawl the db, getting the following error:
    EQP-80407: Exception while processing document: ORA-00918: column ambiguously defined
    Here is the query used while creating the datasource:
    SELECT 'SWERowId0='||SR.ROW_ID||''AS URL,SR.ROW_ID AS KEY, 'en' AS LANG,SR.LAST_UPD AS LASTMODIFIEDDATE,'SR#: ' ||SR.SR_NUM || CHR(13) || 'Asset Business Segment: '||O.NAME || CHR(13) || 'Installed At Customer Short Name: ' ||OX.ATTRIB_07 || CHR(13) ||'Dispatch To Last Name: ' ||CON.LAST_NAME || CHR(13) || 'Version: ' ||SRX.ATTRIB_07 || CHR(13) || 'Asset Description: ' ||ASS.DESC_TEXT || CHR(13) ||'Short Description: ' ||SR.X_GEHC_IITS_SHORT_DESCRIPTION || CHR(13) || 'Status: ' ||SR.SR_STAT_ID || CHR(13)|| 'Responsible Queue: ' ||USR.LOGIN || CHR(13) || 'Created Date: ' ||SR.X_GEHC_IITS_CREATED || CHR(13) || 'Resolution: '||SR.X_RESOLUTION || CHR(13) || 'SPR ID: ' ||SRX.ATTRIB_41|| CHR(13) || 'Type: ' ||SR.SR_CAT_TYPE_CD || CHR(13) || 'SubType: ' ||SR.SR_SUBTYPE_CD || CHR(13) || 'Description:
    '||SR.DESC_TEXT || CHR(13) || 'Actual Problem: '|| SR.X_ACTUAL_PROBLEM || CHR(13) || 'Owner Last Name: '|| emp.LAST_NAME || CHR(13) || CHR(13) || 'Action: ' ||ACT.SUBTYPE_CD || CHR(13) || 'Type: ' ||ACT.TODO_CD || CHR(13) || 'Status: ' ||ACT.EVT_STAT_CD || CHR(13) || 'Comments: '||ACT.COMMENTS_LONG || CHR(13) ||CHR(13) ||CHR(13) || 'SR#: ' ||SR.SR_NUM || CHR(13) || 'Customer Name: ' ||ORG.NAME || CHR(13) || 'Created Date/Time: '||ACT.X_GEHC_IITS_CREATED || CHR(13) || 'Last Updated Date/Time: '||ACT.LAST_UPD || CHR(13)|| 'Asset Business Segment: '||O.NAME || CHR(13) || 'Asset Description: ' ||ASS.DESC_TEXT || CHR(13) || 'Version: ' ||SRX.ATTRIB_07 || CHR(13) || 'Responsible Queue: ' ||USR.LOGIN ||CHR(13) || 'Customer Short Name: '||OX.ATTRIB_07 || CHR(13) || 'SR Owner First Name: ' ||emp.FST_NAME || CHR(13) || 'SR Owner Last Name: '||emp.LAST_NAME || CHR(13) || 'Customer Contact: ' ||CON3.LAST_NAME|| CHR(13) || 'Owner Last Name: ' ||CON4.LAST_NAME as CONTENT,
    'SR #:' ||SR.SR_NUM || ' - ' || 'Activity#: ' ||ACT.ACTIVITY_UID as title,
    SR.SR_NUM as SR#,
    O.NAME as ASSETBUSINESSSEGMENT,
    OX.ATTRIB_07 as INSTALLEDATCUSTOMERSHORTNAME,
    CON.LAST_NAME as DISPATCHTOLASTNAME,
    SRX.ATTRIB_07 as VERSION,
    SR.SR_STAT_ID as SRSTATUS,
    USR.LOGIN as RESPONSIBLEQUEUE,
    SR.X_GEHC_IITS_CREATED as CREATEDDATE,
    ASS.DESC_TEXT as ASSETDESCRIPTION,
    SR.X_GEHC_IITS_SHORT_DESCRIPTION as SHORTDESCRIPTION,
    emp.LAST_NAME as OWNERLASTNAME,
    CON2.LAST_NAME as CONTACTLASTNAME,
    SR.LAST_UPD as LASTEDITEDUPDATEDDATE,
    ACT.EVT_STAT_CD as ACTIVITYSTATUS,
    ACT.X_GEHC_IITS_CREATED as CREATEDDATETIME,
    ACT.LAST_UPD as LASTUPDATEDDATETIME,
    CON3.LAST_NAME as CUSTOMERCONTACT,
    CON4.LAST_NAME as OWNERLASTNAME
    FROM SIEBEL.S_SRV_REQ SR,SIEBEL.S_ASSET ASS,SIEBEL.S_ORG_EXT O,SIEBEL.S_ORG_EXT_X OX,SIEBEL.S_CONTACT CON,SIEBEL.S_CONTACT emp,SIEBEL.S_SRV_REQ_X SRX,SIEBEL.S_CONTACT CON2,SIEBEL.S_USER USR,SIEBEL.S_EVT_ACT ACT,SIEBEL.S_CONTACT CON3,SIEBEL.S_CONTACT CON4 ,SIEBEL.S_ORG_EXT ORG,SIEBEL.S_ACT_CONTACT CONACT WHERE SR.ASSET_ID = ASS.ROW_ID(+) AND ASS.BU_ID = O.PAR_ROW_ID(+) AND SR.CST_OU_ID=OX.PAR_ROW_ID(+) AND SR.X_DISPATCH_ID=CON.PAR_ROW_ID(+) AND SR.OWNER_EMP_ID=EMP.PAR_ROW_ID(+) AND SR.ROW_ID=SRX.PAR_ROW_ID(+) AND SR.CST_CON_ID=CON2.PAR_ROW_ID(+) AND SR.X_GEHC_IITS_QUEUE_OWNER = USR.ROW_ID(+) AND SR.ROW_ID = ACT .SRA_SR_ID(+) AND ACT.OWNER_PER_ID = CON4.PAR_ROW_ID(+) AND SR.CST_OU_ID = ORG.PAR_ROW_ID(+) AND ACT.ROW_ID = CONACT.ACTIVITY_ID(+) AND CONACT.CON_ID = CON3.ROW_ID(+) and SR.LAST_UPD >= to_date('10/14/2011','MM/DD/YYYY')
    Here is the snippet of the crawler log:
    06:05:21:307 INFO     filter_0          Queueing URL:http://iits-web-dev-01.am.health.ge.com:10091/emedical_enu/start.swe?SWECmd=GotoView&SWEView=Defects+Detail&SWERF=1&SWEBU=1&SWEApplet0=Product+Defect+Detail+Form+Applet&SWERowId0=1-2PDOEF, key:1-2PDOEF, lastmod:2011-10-13T06:25:09
    06:05:21:314 DEBUG     filter_1     JdbcDocumentQueueManager          batch dequeue(ms): 6 (5678859)
    06:05:21:314 INFO     filter_1          Dequeued http://iits-web-dev-01.am.health.ge.com:10091/emedical_enu/start.swe?SWECmd=GotoView&SWEView=Defects+Detail&SWERF=1&SWEBU=1&SWEApplet0=Product+Defect+Detail+Form+Applet&SWERowId0=1-2PDOEF
    06:05:21:314 DEBUG     filter_1          Access url is http://foo?key=1-2PDOEF&lastmod=2011-10-13T06:25:09 KEYVAL is 1-2PDOEF
    06:05:21:314 DEBUG     filter_0     JdbcDocumentQueueManager          existing Query(ms):0
    06:05:21:320 FATAL     filter_1          EQP-80407: Exception while processing document: ORA-00918: column ambiguously defined
    06:05:21:320 FATAL     filter_1     ORA-00918: column ambiguously defined
    java.sql.SQLException     oracle.jdbc.driver.DatabaseError:throwSqlException:125     oracle.jdbc.driver.T4CTTIoer:processError:316     oracle.jdbc.driver.T4CTTIoer:processError:282     oracle.jdbc.driver.T4C8Oall:receive:639     oracle.jdbc.driver.T4CPreparedStatement:doOall8:185     oracle.jdbc.driver.T4CPreparedStatement:execute_for_describe:503     oracle.jdbc.driver.OracleStatement:execute_maybe_describe:965     oracle.jdbc.driver.T4CPreparedStatement:execute_maybe_describe:535     oracle.jdbc.driver.OracleStatement:doExecuteWithTimeout:1051     oracle.jdbc.driver.OraclePreparedStatement:executeInternal:2984     oracle.jdbc.driver.OraclePreparedStatement:executeQuery:3026     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:processDocuments:1084     oracle.search.plugin.appsjdbc.AppsJdbcPlugin:crawl:1456     oracle.search.crawler.CrawlingThread:run:1578
    We are using LAST_NAME column at diffrenet places in the query from S_CONTACT table using different joins. when I run the same query in SQL, not getting any error as we are using different join aliases.This is happening only when I use the same query to crawl the data in SES datasource.
    Any help on this would be highly appreciated.

    Hi Roger,
    Query format: SELECT * FROM (< your query >) WHERE KEY=<value>
    Can you please tell me what could be the value for "KEY=<value>"
    I have executed the query in SQL*Plus,as per the format as follows by passing sample row id of one record as KEY, but getting the Column ambiguity error.
    SELECT * FROM (SELECT 'SWERowId0='||SR.ROW_ID||''AS URL,SR.ROW_ID AS KEY, 'en' AS LANG,SR.LAST_UPD AS LASTMODIFIEDDATE,'SR#: ' ||SR.SR_NUM || CHR(13) || 'Asset Business Segment: '||O.NAME || CHR(13) || 'Installed At Customer Short Name: ' ||OX.ATTRIB_07 || CHR(13) || 'Dispatch To Last Name: ' ||CON.LAST_NAME || CHR(13) || 'Version: ' ||SRX.ATTRIB_07 || CHR(13) || 'Asset Description: ' ||ASS.DESC_TEXT || CHR(13) || 'Short Description: ' ||SR.X_GEHC_IITS_SHORT_DESCRIPTION || CHR(13) || 'Status: ' ||SR.SR_STAT_ID || CHR(13) || 'Responsible Queue: ' ||USR.LOGIN || CHR(13) || 'Created Date: ' ||SR.X_GEHC_IITS_CREATED || CHR(13) || 'Resolution: '||SR.X_RESOLUTION || CHR(13) || 'SPR ID: ' ||SRX.ATTRIB_41|| CHR(13) || 'Type: ' ||SR.SR_CAT_TYPE_CD || CHR(13) || 'SubType: ' ||SR.SR_SUBTYPE_CD || CHR(13) || 'Description: '||SR.DESC_TEXT || CHR(13) || 'Actual Problem: '|| SR.X_ACTUAL_PROBLEM || CHR(13) || 'Owner Last Name: '|| emp.LAST_NAME || CHR(13) || CHR(13) || 'Action: ' ||ACT.SUBTYPE_CD || CHR(13) || 'Type: ' ||ACT.TODO_CD || CHR(13) || 'Status: ' ||ACT.EVT_STAT_CD || CHR(13) || 'Comments: '||ACT.COMMENTS_LONG || CHR(13) ||CHR(13) ||CHR(13) || 'SR#: ' ||SR.SR_NUM || CHR(13) || 'Customer Name: ' ||ORG.NAME || CHR(13) || 'Created Date/Time: '||ACT.X_GEHC_IITS_CREATED || CHR(13) || 'Last Updated Date/Time: '||ACT.LAST_UPD || CHR(13) || 'Asset Business Segment: '||O.NAME || CHR(13) || 'Asset Description: ' ||ASS.DESC_TEXT || CHR(13) || 'Version: ' ||SRX.ATTRIB_07 || CHR(13) || 'Responsible Queue: ' ||USR.LOGIN || CHR(13) || 'Customer Short Name: '||OX.ATTRIB_07 || CHR(13) || 'SR Owner First Name: ' ||emp.FST_NAME || CHR(13) || 'SR Owner Last Name: ' ||emp.LAST_NAME || CHR(13) || 'Customer Contact: ' ||CON3.LAST_NAME|| CHR(13) || 'Owner Last Name: ' ||CON4.LAST_NAME as CONTENT,'SR #:' ||SR.SR_NUM || ' - ' || 'Activity#: ' ||ACT.ACTIVITY_UID as title,SR.SR_NUM as SR#,O.NAME as ASSETBUSINESSSEGMENT,OX.ATTRIB_07 as INSTALLEDATCUSTOMERSHORTNAME,CON.LAST_NAME as DISPATCHTOLASTNAME,SRX.ATTRIB_07 as VERSION,SR.SR_STAT_ID as SRSTATUS,USR.LOGIN as RESPONSIBLEQUEUE,SR.X_GEHC_IITS_CREATED as CREATEDDATE,ASS.DESC_TEXT as ASSETDESCRIPTION,SR.X_GEHC_IITS_SHORT_DESCRIPTION as SHORTDESCRIPTION,emp.LAST_NAME as OWNERLASTNAME,CON2.LAST_NAME as CONTACTLASTNAME,SR.LAST_UPD as LASTEDITEDUPDATEDDATE,ACT.EVT_STAT_CD as ACTIVITYSTATUS,ACT.X_GEHC_IITS_CREATED as CREATEDDATETIME,ACT.LAST_UPD as LASTUPDATEDDATETIME,CON3.LAST_NAME as CUSTOMERCONTACT,CON4.LAST_NAME as OWNERLASTNAME FROM SIEBEL.S_SRV_REQ SR,SIEBEL.S_ASSET ASS,SIEBEL.S_ORG_EXT O,SIEBEL.S_ORG_EXT_X OX,SIEBEL.S_CONTACT CON,SIEBEL.S_CONTACT emp,SIEBEL.S_SRV_REQ_X SRX,SIEBEL.S_CONTACT CON2,SIEBEL.S_USER USR,SIEBEL.S_EVT_ACT ACT,SIEBEL.S_CONTACT CON3,SIEBEL.S_CONTACT CON4 ,SIEBEL.S_ORG_EXT ORG,SIEBEL.S_ACT_CONTACT CONACT WHERE SR.ASSET_ID = ASS.ROW_ID(+) AND ASS.BU_ID = O.PAR_ROW_ID(+) AND SR.CST_OU_ID=OX.PAR_ROW_ID(+) AND SR.X_DISPATCH_ID=CON.PAR_ROW_ID(+) AND SR.OWNER_EMP_ID=EMP.PAR_ROW_ID(+) AND SR.ROW_ID=SRX.PAR_ROW_ID(+) AND SR.CST_CON_ID=CON2.PAR_ROW_ID(+) AND SR.X_GEHC_IITS_QUEUE_OWNER = USR.ROW_ID(+) AND SR.ROW_ID = ACT .SRA_SR_ID(+) AND ACT.OWNER_PER_ID = CON4.PAR_ROW_ID(+) AND SR.CST_OU_ID = ORG.PAR_ROW_ID(+) AND ACT.ROW_ID = CONACT.ACTIVITY_ID(+) AND CONACT.CON_ID = CON3.ROW_ID(+)) WHERE KEY='1-1MCO39'
    Please help me.
    Thanks
    Sandeep

  • Join the same view using 2 different conditions, getting error ORA-00918

    Hi, I am trying to do a full outer join using the same view with different where conditions. Sample code below. I am getting the error "ORA-00918: column ambiguously defined". I have used as much alias as I can on the select statements but it gives me the same error.
    The weird thing is, RIGHT OUTER JOIN and LEFT OUTER JOIN will work fine. Only FULL OUTER gives the error above.
    Thanks in advance for your help.
    SELECT firsttable.<column_name>, secondtable.<columnname>
    FROM
    SELECT ...
    FROM V_MYVIEW
    WHERE <column_name> IN (1,2)
    ) firsttable
    FULL OUTER JOIN
    SELECT ...
    FROM V_MYVIEW
    WHERE <column_name> IN (3,4)
    ) secondtable
    ON firsttable.<column_name> and secondtable.<column_name>

    ON firsttable.<column_name> and secondtable.<column_name> ON firsttable.<column_name> = secondtable.<column_name>

  • ORA-00918 issue joining tables for Update

    Hi,
    I have 2 tables : PAR_SPEC_OPS and T_PAR and I'm trying to update 2 columns in the first one with values from the second table.
    Here's my script :
    Update
    Select membership_id, membership_status
    From Par_Spec_Ops P,T_Par T
    Where P.Tracking_ID=T.Tracking_ID
    Set P.membership_id = T.membership_id,
    P.membership_status = T.membership_status;
    Running this gives me ORA-00918: column ambiguously defined. I've looked this up and it says it happens when there's a common column in the 2 tables and I'm not using prefixes, but as you can see from my command, I'am using prefixes. I have tried with and without alias but I get the same error.
    Do you guys have any ideas?
    Thanks and regards,
    Ionut
    Edited by: 837311 on Nov 8, 2011 4:24 AM

    Does this help?
    SQL> create table t_par
    2 (membership_id number,
    3 membership_status varchar2(10),
    4 tracking_id number
    5 );
    Table created.
    SQL>
    SQL> create unique index t_par_ix1 on t_par(tracking_id);
    Index created.
    SQL>
    SQL> create table par_spec_ops
    2 (membership_id number,
    3 membership_status varchar2(10),
    4 tracking_id number
    5 );
    Table created.
    SQL>
    SQL> create unique index tracking_id_ix1 on par_spec_ops(tracking_id);
    Index created.
    SQL>
    SQL> insert into t_par values(111,'new',1111);
    1 row created.
    SQL> insert into t_par values(222,'new',2222);
    1 row created.
    SQL> insert into t_par values(333,'new',3333);
    1 row created.
    SQL>
    SQL> insert into par_spec_ops values(111,'expired',1111);
    1 row created.
    SQL> insert into par_spec_ops values(222,'expired',2222);
    1 row created.
    SQL>
    SQL> Select t.membership_id, t.membership_status,p.membership_id,p.membership_status
    2 From T_Par T left outer join par_spec_ops p using(tracking_id)
    3 ;
    MEMBERSHIP_ID MEMBERSHIP MEMBERSHIP_ID MEMBERSHIP
         111 new          111 expired
         222 new          222 expired
         333 new
    SQL>
    SQL> Update
    2 (
    3 Select p.membership_id as p_m_id,
    4      t.membership_id as t_m_id,
    5      t.membership_status t_m_stat,
    6      p.membership_status p_m_stat
    7 From Par_Spec_Ops P,T_Par T
    8 Where P.Tracking_ID=T.Tracking_ID
    9 )
    10 Set p_m_id = t_m_id,
    11 p_m_stat = t_m_stat;
    2 rows updated.
    SQL>
    SQL> Select t.membership_id, t.membership_status,p.membership_id,p.membership_status
    2 From T_Par T left outer join par_spec_ops p using(tracking_id)
    3 ;
    MEMBERSHIP_ID MEMBERSHIP MEMBERSHIP_ID MEMBERSHIP
         111 new          111 new
         222 new          222 new
         333 new
    SQL>

  • Ambiguous Column Naming Error In Query

    I'm getting a strange Oracle error when I try and run a (relatively)
    straightforward query.
    This is the error I get:
    ORA-12801: error signaled in parallel query server P000
    ORA-00960: ambiguous column naming in select list
    This is the query that Kodo is generating:
    SELECT DISTINCT
         t0.EVENT_ID, t0.ACTIVE_YN, t0.CREAT_BY, t0.CREAT_DT,
    t0.REPORTED_CURNCY_CD,
         t0.PUB_DESCR_TX, t0.FREQUENCY, t0.MOD_BY, t0.MOD_DT, t0.EVENT_NAME,
    t0.CLI_ID,
         t0.ORG_UNIT_ID, t0.RATING_CD, t0.TOTAL_MONEY, t0.RISK_CLASS_ID, t0.TYPE,
         t0.STATUS_ID, t0.LOSS_LOC_CUR, t0.EVENT_TYPE, t0.EVENT_NAME
    FROM
         DEF_EVENT_DATE t2, EVENT t0, EVENT_DATE t1
    WHERE
         (((t2.DATE_TYPE_CD = 'Start Occurrence Date' AND
         t1.VALUE_DT <= {ts '2002-10-09 14:17:02.422'}) AND
         t0.CLI_ID = 2963) AND
         t0.EVENT_ID = t1.EVENT_ID AND
         t1.DATE_TYPE_CD = t2.DATE_TYPE_CD)
    ORDER BY
         t0.EVENT_NAME ASC
    t0.EVENT_NAME is being selected twice. I am guessing this has something to
    do with the ORDER BY clause.
    But in conjunction with the DISTINCT keyword this is breaking the query.
    This can be shown in the following simple example:
    SELECT DISTINCT
         t0.EVENT_NAME, t0.EVENT_NAME
    FROM
         EVENT t0
    ORDER BY
         t0.EVENT_NAME ASC;
    This throws the same 'ambiguous column' error as before.
    My question is why is the DISTINCT keyword being used in this query and
    how do I fix it?
    Thanks in advance,
    Simon

    i'm not sure,
    but the problem you reported tends to be an oracle problem.
    (selecting a column twice should be not a problem)
    the ORA-error you reported is a parallel query error ...
    and parallel queries are bound to some special conditions ...
    try: alter table <table> parallel 1
    and apply your test again.
    "Simon Horne" <[email protected]> schrieb im Newsbeitrag
    news:ao1js8$i6r$[email protected]..
    I'm getting a strange Oracle error when I try and run a (relatively)
    straightforward query.
    This is the error I get:
    ORA-12801: error signaled in parallel query server P000
    ORA-00960: ambiguous column naming in select list
    This is the query that Kodo is generating:
    SELECT DISTINCT
    t0.EVENT_ID, t0.ACTIVE_YN, t0.CREAT_BY, t0.CREAT_DT,
    t0.REPORTED_CURNCY_CD,
    t0.PUB_DESCR_TX, t0.FREQUENCY, t0.MOD_BY, t0.MOD_DT, t0.EVENT_NAME,
    t0.CLI_ID,
    t0.ORG_UNIT_ID, t0.RATING_CD, t0.TOTAL_MONEY, t0.RISK_CLASS_ID, t0.TYPE,
    t0.STATUS_ID, t0.LOSS_LOC_CUR, t0.EVENT_TYPE, t0.EVENT_NAME
    FROM
    DEF_EVENT_DATE t2, EVENT t0, EVENT_DATE t1
    WHERE
    (((t2.DATE_TYPE_CD = 'Start Occurrence Date' AND
    t1.VALUE_DT <= {ts '2002-10-09 14:17:02.422'}) AND
    t0.CLI_ID = 2963) AND
    t0.EVENT_ID = t1.EVENT_ID AND
    t1.DATE_TYPE_CD = t2.DATE_TYPE_CD)
    ORDER BY
    t0.EVENT_NAME ASC
    t0.EVENT_NAME is being selected twice. I am guessing this has something to
    do with the ORDER BY clause.
    But in conjunction with the DISTINCT keyword this is breaking the query.
    This can be shown in the following simple example:
    SELECT DISTINCT
    t0.EVENT_NAME, t0.EVENT_NAME
    FROM
    EVENT t0
    ORDER BY
    t0.EVENT_NAME ASC;
    This throws the same 'ambiguous column' error as before.
    My question is why is the DISTINCT keyword being used in this query and
    how do I fix it?
    Thanks in advance,
    Simon

  • Oracle is adding "RowId" to select statement = ORA-00918 follows

    Hi,
    i've a problem with a strange case:
    Oracle adds a rowId column to the select - and this select has joins to 2 other tables and a ora-00918 is the result!
    But my application don't throw a java-excpetion - this appears only in the database log files - in the application, no problem is determined!
    Database is suffering under this statement because in an hour, 1800 statements are failing... so what could this be and how i can prevent it to add this column!?
    select rowid, t1.name, .......... from t1, t2, t3 etc....
    I use the following statement:
    Statement selStmt = stmt.getConnection().createStatement(
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
    Thx for help!
    lg
    Manny

    Tough to help if you don't provide you Java and OS infor and the Oracle JDBC driver version.
    Post all of the relevant Java code that is used to setup and execute the prepared statement and handle the result set.
    The Oracle JDBC driver uses ROWID to support scroll sensitive or updatable result sets so it is probably being added for this reason.
    Remove the 'TYPE_SCROLL_SENSITIVE' setting and see if the problem goes away.
    Seacrh for ROWID in the JDBC Dev guide (Chap 17) - http://www.stanford.edu/dept/itss/docs/oracle/10g/java.101/b10979/resltset.htm
    >
    17.1.2.2 Oracle JDBC Implementation for Result Set Updatability
    To support updatability, Oracle JDBC uses ROWIDs to uniquely identify database rows that appear in a result set. For every query into an updatable result set, the Oracle JDBC driver automatically retrieves the ROWID along with the columns you select.
    >
    And since you are trying to produce a scroll sensitive result set you should do a test as described in this doc hint:
    >
    There is a simple way to determine if your query will probably produce a scroll-sensitive or updatable result set: If you can legally add a ROWID column to the query list, then the query is probably suitable for either a scroll-sensitive or an updatable result set. (You can try this out using SQL*Plus, for example.)
    >
    and:
    >
    The Oracle JDBC drivers use the ROWID to uniquely identify a row in a database table. As long as the ROWID is still valid when a driver tries to send an UPDATE or DELETE operation to the database, the operation will be executed.
    >
    Hope that helps.

  • Dynamic ordering ambiguous column issue

    I'm working on a stored procedure that will accept a column name from a web application.  The stored procedure will use the @SortColumn to sort the results of the query.  I'm receiving ambiguous column errors when the column values are passed in
    to the query.  The original query is written using dynamic sql but I created a simple query to reproduce the issue.   Can someone review the sample below and let me know if there is a way to resolve the error. 
    In the example below, the Over(Order by Emp_ID) section is causing the error. The order by is expecting e.Emp_ID as the order by value.  Is there anyway for me to rewrite the logic to allow the correct column alias to be using in the order by statement? 
    Ultimately, I would like to pass in a paramter for the order by column.  Ex.   Over(Order by ' + @SortColunm + '
    SELECT RowNum
    ,Emp_ID
    ,First_Name
    ,Last_Name
    From (Select Distinct ROW_NUMBER() OVER(Order by Emp_ID) as RowNum,
    e.Emp_ID as Emp_ID
    ,e.First_Name as First_Name
    ,e.Last_Name as Last_Name
    FROM Employee e
    LEFT OUTER JOIN Team t ON e.team_id = t.team_Id AND e.Emp_id = t.Emp_Id
    LEFT OUTER JOIN AccrualType at ON e.Accrual_Type = at.Type
    LEFT OUTER JOIN ClosingProcess cp ON e.Emp_id = cp.Emp_ID
    where Last_Name like 's%'
    ) As Employees
    order by Emp_ID

    I've updated my query to use a cte and also included the Row_Number logic.  I'm now receiving "Invalid column name 'RowNum".  Can anyone explain what I'm doing wrong in the code below?   I'm trying to create a stored procedure
    that accepts a parameter to handle paging and sorting.  The dynamic sql is needed for the SortExpression.
    declare @SortExpression varchar(50) = 'Last_Name';
    declare @DynSql varchar(max)='';
    declare @Emp_ID NVARCHAR(50) = NULL
    declare @First_Name VARCHAR(50) = NULL
    declare @Last_Name VARCHAR(50) = 's'
    declare @StartIndex INT
    declare @MaximumRows INT
    set @DynSql=
    With Employees as
    ( Select Distinct
    e.Emp_ID as Emp_ID
    ,First_Name
    ,Last_Name
    FROM Employee e
    LEFT OUTER JOIN Team t ON e.team_id = t.team_Id AND e.Emp_id = t.Emp_Id
    LEFT OUTER JOIN AccrualType at ON e.Accrual_Type = at.Type
    LEFT OUTER JOIN ClosingProcess cp ON e.Emp_id = cp.Emp_ID
    SELECT ROW_NUMBER() Over (Order By ' + @SortExpression + ') As RowNum,
    Emp_ID
    ,First_Name
    ,Last_Name
    FROM Employees
    WHERE RowNum BETWEEN ' + CAST(@StartIndex as varchar(10)) + ' AND ' + '(' + CAST(@StartIndex as varchar(10))+ CAST(@MaximumRows as varchar(10))+ ') - 1 '
    If @Emp_ID is not null
    Set @DynSql = @DynSql + ' And (Emp_ID = @Emp_ID)'
    If @First_Name is not null
    Set @DynSql = @DynSql + ' And (First_Name = @First_Name)'
    If @Last_Name is not null
    Set @DynSql = @DynSql + ' And (Last_Name = @Last_Name)'
    exec (@DynSql)

  • Ambiguous column name 'ITEMCODE'.

    hi,
      while executing the query by using stored procedures
    i got this error."Ambiguous column name 'ITEMCODE' ".
    -priya

    Hi priyadharshini
    The error usually means your are joining multiple tables,
    and doesn't clearly state from which table you're trying to retrieve the column.
    Please have a look at this page.
    http://databases.aspfaq.com/database/what-does-ambiguous-column-name-mean.html 
    Regards,
    Syn Qin
    SAP Business One Forums Team

  • ORA-01461: can bind a LONG value only for insert into a LONG column ORA-020

    Getting error --
    ORA-01461: can bind a LONG value only for insert into a LONG column ORA-02063: preceding line from APPS
    A page has 3 fields and a Add button
    (1) first field is a LOV "select with submit"
    (2) second field is getting its value from select statement with where clause = ID selected from field1
    (3) field 3 is the value of field1
    In After submit Process , I write simple insert as follows in the
    BEGIn
    INSERT INTO TABLE_NAME (ELEMENT_NAME,ELEMENT_TYPE_ID )
    VALUES (:P3_NAME ,to_number(:P3_ELEMENT_TYPE_ID));
    COMMIT;
    END;
    when i click on Add i get the error above

    try doing the bind locally before executing the remote dml...
    declare
    l_long long := :P3_NAME;
    begin
    insert into table_name (ELEMENT_NAME,ELEMENT_TYPE_ID )
    values (l_long ,to_number(:P3_ELEMENT_TYPE_ID));
    end;
    ...and if that doesn't work, please let us know the definition of you TABLE_NAME table.
    thanks,
    raj

  • AMBIGUOUS COLUMN DEFINITION

    I'M GETTING "AMBIGUOUS COLUMN DEFINITION" WHICH IS CLEARLY WRONG SO HOW DO I FIX IT ?

    user8093006 wrote:
    I'M GETTING "AMBIGUOUS COLUMN DEFINITION" WHICH IS CLEARLY WRONG SO HOW DO I FIX IT ?
    To explain what is happening. It is called name resolution.
    You use object names in code - where the object you refer to by name can be a function, procedure, variable, parameter, constant, global, etc. In SQL code, this also includes columns, tables, views, and so on.
    You get name collisions. This is when 2 objects have the same name. In SQL this often happens (and should happen!). The DEPT table has a column (primary key) called DEPT_ID. The EMP table indicates which department the employee works for, via its column (foreign key) DEPT_ID.
    So the name reference DEPT_ID is used multiple times by multiple tables.
    When you use DEPT_ID in a SQL statement, the SQL engine needs to resolve that name and determine to which column in which table you are referring to. This name resolution has a scope. The scope says which tables need to be considered (checked) for having a DEPT_ID column. The scope is determined (in this case) by the tables your SQL is selecting from.
    Now if your scope includes both EMP and DEPT tables, there is a name collision - and the SQL engine does not know whether your DEPT_ID name refers to the column in the EMP table, or the column in the DEPT table.
    And this is the error you are seeing. The SQL engine is saying that your name reference DEPT_ID is ambiguous, as it exists as different objects within that SQL's resolution scope.
    The fix is explicit scope. Where you do not use DEPT_ID and have the SQL engine figure out in which table it is (within the current scope) - instead you tell that to the SQL engine and indicate which table it is in.
    There are 2 method to use explicit scope in SQL. You can do that via using the name of the owner of the object - in this case, the name of the table that owns that column:
    select
        dept.dept_id,
        dept.department_name,
        emp.surname
    from dept, emp
    where dept.dept_id = emp.dept_id
    Or you can use aliasing (less typing and a bit more flexible ito code maintenance):
    select
        d.dept_id,
        d.department_name,
        e.surname
    from dept d, emp e
    where d.dept_id = e.dept_id
    Explicit scope is usually a good thing. Where implicit scope is needed, a feature such as synonyms should be considered (it allows explicit scope to be used, while enabling one to easily change the object that the name resolves to).

  • Adding virtual column: ORA-12899: value too large for column

    I'm using Oracle 11g, Win7 OS, SQL Developer
    I'm trying to add virtual column to my test table, but getting ORA-12899: value too large for column error. Below are the details.
    Can someone help me in this?
    CREATE TABLE test_reg_exp
    (col1 VARCHAR2(100));
    INSERT INTO test_reg_exp (col1) VALUES ('ABCD_EFGH');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_ABC');
    INSERT INTO test_reg_exp (col1) VALUES ('WXYZ_ABCD');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCDE_PQRS');
    INSERT INTO test_reg_exp (col1) VALUES ('ABCD_WXYZ');
    ALTER TABLE test_reg_exp
    ADD (col2 VARCHAR2(100) GENERATED ALWAYS AS (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_')));
    SQL Error: ORA-12899: value too large for column "COL2" (actual: 100, maximum: 400)
    12899. 00000 -  "value too large for column %s (actual: %s, maximum: %s)"
    *Cause:    An attempt was made to insert or update a column with a value
               which is too wide for the width of the destination column.
               The name of the column is given, along with the actual width
               of the value, and the maximum allowed width of the column.
               Note that widths are reported in characters if character length
               semantics are in effect for the column, otherwise widths are
               reported in bytes.
    *Action:   Examine the SQL statement for correctness.  Check source
               and destination column data types.
               Either make the destination column wider, or use a subset
               of the source column (i.e. use substring).When I try to select, I'm getting correct results:
    SELECT col1, (REGEXP_REPLACE (col1, '^ABCD[A-Z]*_'))
    FROM test_reg_exp;Thanks.

    Yes RP, it working if you give col2 size >=400.
    @Northwest - Could you please test the same w/o having a regex clause in col2?
    I doubt on the usage of a REGEX in this dynamic col case.
    Refer this (might help) -- http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
    Below snippet from above link.... see if this helps...
    >
    Notes and restrictions on virtual columns include:
    Indexes defined against virtual columns are equivalent to function-based indexes.
    Virtual columns can be referenced in the WHERE clause of updates and deletes, but they cannot be manipulated by DML.
    Tables containing virtual columns can still be eligible for result caching.
    Functions in expressions must be deterministic at the time of table creation, but can subsequently be recompiled and made non-deterministic without invalidating the virtual column. In such cases the following steps must be taken after the function is recompiled:
    Constraint on the virtual column must be disabled and re-enabled.
    Indexes on the virtual column must be rebuilt.
    Materialized views that access the virtual column must be fully refreshed.
    The result cache must be flushed if cached queries have accessed the virtual column.
    Table statistics must be regathered.
    Virtual columns are not supported for index-organized, external, object, cluster, or temporary tables.
    The expression used in the virtual column definition has the following restrictions:
    It cannot refer to another virtual column by name.
    It can only refer to columns defined in the same table.
    If it refers to a deterministic user-defined function, it cannot be used as a partitioning key column.
    The output of the expression must be a scalar value. It cannot return an Oracle supplied datatype, a user-defined type, or LOB or LONG RAW.
    >
    Edited by: ranit B on Oct 16, 2012 11:48 PM
    Edited by: ranit B on Oct 16, 2012 11:54 PM

  • Materialized View cannot use filter columns ORA-12033

    Hello Forum members,
    I am creating the following MV with Can you please advise me??
    Thanks
    SQL> create materialized view log on his_swi with rowid including new values;
    Materialized view log created.
    SQL>
    SQL> CREATE MATERIALIZED VIEW His_Swi_mv
    2 refresh fast with rowid
    3 AS
    4 select quarter,sum(sw_po),sum(sw_po_fre),
    5 sum(sw_por_sta+sw_porunt_swi+sw_por_hb+sw_po_free) as proj from
    6 history_switch group by quarter;
    his_swi group by quarter
    ERROR at line 6:
    ORA-12033: cannot use filter columns from materialized view log on
    "EM"."HIS_SWI"

    Hello Forum members,
    Please ignore the above post.
    got solution from : http://www.jusungyang.com/DWfolder/MaterializedViews/MVlogFilterColumns.txt
    Thanks

Maybe you are looking for

  • Bootcamp can only open Windows 7 in Safe Mode

    I've been using Bootcamp to play my old computer games on my Macbook Pro for about two years now, and I've never had any issues before now. Last night, I bought a game from Origin and found that it was taking a lot longer to download than I had expec

  • Logo not displayed in pdf

    Hi all when i convert from  spool to pdf using the the function module "CONVERT_OTFSPOOLJOB_2_PDF" ,and store the pdf in front end ,the logo is displayed. However when i store the pdf in application server directory( unix) and retrieve the PDF later

  • GarageBand 10.0 Only creates 20 second ringtones, even though the help says 40 seconds

    All - I just upgraded my iMac 3.06 to Mavericks, and downloaded the 10.0 GarageBand. Before a hard drive failure I had the version of iLife that came with my iMac with that version of GarageBand - lost the install disc, etc etc. I used to create and

  • Tax calculation matter - GL a/c with service tax chargeable

    Dear Experts, I really do not understand why this happen. Any expert can help me? Thank you. GL posting for C/N issued:- Car Park reversal         129.03 Service Tax 5%               6.45 Total =                        135.48 <PROBLEM> Document C/N p

  • Question about OO Systems

    I've been wondering this for a while now. I had to design and build a software system for college as a project and i was going to design the classes attributes methods etc. but then i realized i would need a database to store the information and i co