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

Similar Messages

  • Interactive Report's Column Definition - Single Row View Label Bug?

    Hello,
    I have an Interactive report that I've added a Blue background to certain column headings (done by giving Column Heading a background color), this works fine except for the Single Row view - it displays the <....> code I used to get the background color and the column heading. I've tried to change the Single Row View Label by unchecking the 'Use Same Text for Single Row View' on the Column Definition and giving a different label, it just ignores whatever I put in and shows the Column Heading with the < .... > code. Is this a Bug or am I doing something wrong?
    Thanks,
    Anna

    Hi Anna,
    I believe that it is a bug.
    If the 'Use Same Text for Single Row View' checkbox is unticked and some text is entered in the 'Single Row View Label' field it gets ignored completely when viewed in the single row view and the existing value in 'Column Heading' is used.
    I wanted to do something similar to you, colouring some of the Interactive Report column headers, and it works fine in the IR report itself but shows the code (span style:color etc) in the single row query. I am using Apex 3.1.1 and the Sand Theme.
    I created a simple application on apex.oracle.com using the red theme and in single row view it still ignores the 'Single Row View Label' but interestingly shows the Column Heading text without the code. This indicates that there could be a work-around by altering the theme.
    Regards,
    Chris

  • 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 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

  • Data type in column definition

    Hi,
    I create a table with column called "Direction of Travel code ".
    The travel codes in the functional spec are numbers.
    In the column definition which one is efficient to define the data type as number or varchar?
    Code
    1      
    2      
    3      
    4      
    5      
    6      
    7      
    8      
    9      
    0

    tijmen wrote:
    Tubby wrote:
    And then when you issue a query and ask for travel codes 2 through 10 the CBO can't determine that there are 8 values (cardinality wise) because you're not storing the data type in the format you should be storing it as. Statistics? Perhaps even histograms?
    Simple testcase:
    create table t1(x number(1)) as select mod(rownum, 10) from all_objects where rownum <= 100;
    create table t2(x varchar2(1)) as select to_char(mod(rownum, 10)) from all_objects where rownum <= 100;
    exec dbms_stats.gather_table_stats(user, 'T1', method_opt => 'FOR ALL COLUMNS SIZE 1');
    exec dbms_stats.gather_table_stats(user, 'T2', method_opt => 'FOR ALL COLUMNS SIZE 1');Tried a few simple statements against those (where x = N, where x between N and M), using either literals or bind values. I didn't see any difference in the explain plan...
    Not to mention what happens when someone decides to put an "A" in your travel code that should be only numbers, it will eventually happen.Yes, and that's an input error that should be caught by a database constraint (and possibly even before that by the application). Who knows, the codes 0 and 5 might become obsolete as well with changing business rules. Your number datatype is not going to protest when someone still uses them. Hey, maybe even tomorrow someone from the business will come in and demand for the codes 'a' to 'd' to be created. Histograms, application code and database constraints (which all have side effects and add complexity to the system) as opposed to declaring the data type as a NUMBER (which it is). Doesn't seem like a really good argument for intentionally choosing the wrong data type. Well, at least you didn't suggest a trigger in there as well.
    >
    I'm not saying you should use a char type instead of a number. I'm saying I doubt there's much difference as far as the database is concerned, and I would base the decision on how it works out on the application and business side.As you've found out, the OP stated the functional specs define this as a number. IF in the future the specs change and a business analyst mandates that this support characters as well then the data type gets changed to support the new requirement, no database constraints to remove, no application code to remove, etc...

  • FK Constraints with nonmatching column definitions

    Hello,
    I ran a healthcheck with TOAD and he reported some foreign keys with nonmatching column definitions:
    ! Constraint : HERCULES.LBS_VAL_FK
    ! On Table : HERCULES.LOONBESLAG_SCHULDEISEN
    ! Columns : VAL_CD VARCHAR2 (5)
    ! To Table : HERCULES.VALUTA
    ! Columns : CODE VARCHAR2 (3)
    It also mentions that this causes poor performance because of data conversion.
    But, varchar2 means that each column has a variable length and this length is stored somewhere. So the value of VAL_CD and CODE will be stored in exactly the same way. No data conversion, no poor performance. Right?
    Or am I missing something here?
    Thanks for all the feedback.
    Rik

    I'm quite sure data type conversion doesn't take place here. However the very idea of different types for the PK-FK columns is nonsense, because you cannot fully use this VARCHAR2 (5) column in this case anyway. OK I'm not speaking about deferred constraints :)
    Gints Plivna
    http://www.gplivna.eu

  • 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

  • 2 column definitions for a single table view

    Hi Experts,
    I have a requirement in which i need 2 column definitions for a single table view.
    The requirement is :
    ..............Week1...........              |....................Week2...............
    01/01/2007 |  02/01/2007  |    15/01/2007 | 16/01/2007 | 17/01/2007
    data.......... |  data..........  |    data.......... | data..........  |   data..........      
    data.......... |  data..........  |    data.......... | data..........  |   data..........    
    data.......... |  data..........  |    data.......... | data..........  |   data..........   
    the weeks shud be displayed for the corresponing dates below......
    Is it possible to have 2 column definitions
    Please help me out.
    Thanks in advance

    Hi Balaiji,
    proceed as follows:
    Create a structure in the dictionary called ZSTRU_USR02_F
      with  field1 type int4
              field3 type int4
              field3 type int4
    Create a table type in the dictionary:
    zusr02  line type ZSTRU_USR02_F.
    Create a structure in the dictionary:
    ZSTRU_USR02
      with tab1  type zusr02
      and tab2  type zusr02
    Create a table type in the dictionary:
    zttusr02 line type ZSTRU_USR02
    Create a controller (table.do) in a BSP-application
    Add the controller class to this controller.
    Add a attribute (table) instance public type zttusr02
    redefine method do_request, add the following coding:
      FIELD-SYMBOLS: <fs_tab> LIKE LINE OF table,
                     <fs_row> TYPE zstru_usr02_f.
      DATA: lirv_view TYPE REF TO if_bsp_page,
            lv_int    TYPE i.
    * Dispatch Input for event handling
      dispatch_input( ).
    * Navigation requested during Event handling?
      IF is_navigation_requested( ) IS NOT INITIAL.
        RETURN.
      ENDIF.
    * get some data into the table.
      INSERT INITIAL LINE INTO TABLE table ASSIGNING <fs_tab>.
      DO 3 TIMES.
        INSERT INITIAL LINE INTO TABLE <fs_tab>-tab1 ASSIGNING <fs_row>.
        ADD 1 TO lv_int.
        <fs_row>-field1 = lv_int.
        ADD 1 TO lv_int.
        <fs_row>-field2 = lv_int.
        ADD 1 TO lv_int.
        <fs_row>-field3 = lv_int.
      ENDDO.
      DO 3 TIMES.
        INSERT INITIAL LINE INTO TABLE <fs_tab>-tab2 ASSIGNING <fs_row>.
        ADD 1 TO lv_int.
        <fs_row>-field1 = lv_int.
        ADD 1 TO lv_int.
        <fs_row>-field2 = lv_int.
        ADD 1 TO lv_int.
        <fs_row>-field3 = lv_int.
      ENDDO.
    * Create the view
      lirv_view ?= create_view( view_name = 'table.htm' ).
    * Hand over the data
      lirv_view->set_attribute( name = 'table' value = table ).
    * Call the view
      call_view( lirv_view ).
    Create a view called table.htm. Add your controller class as controller class for the view and add the attribute table type zttusr02.
    Add the following to the layout:
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <htmlb:content design="design2003">
      <htmlb:page title = " ">
        <htmlb:form>
    <htmlb:tableView id             = "tableToDisplay"
                     table          = "<%=table%>"
                     emptyTableText = "No Data"
                     iterator       = "<%=controller%>"
                     footerVisible  = "FALSE"
                     encode         = "TRUE"
                     width          = "100%"/>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    Go back to your controller class. Add the interface IF_HTMLB_TABLEVIEW_ITERATOR
    Implement the method IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS
      DATA: lwa_column  LIKE LINE OF p_column_definitions.
    * Column 1
      CLEAR lwa_column.
      lwa_column-columnname          = 'TAB1'.
      lwa_column-title               = 'Column 1'.
      lwa_column-tooltipheader       = 'Tooltip Column 1'.
      lwa_column-width               = '50%'.
      lwa_column-wrapping            = 'FALSE'.
      lwa_column-horizontalalignment = 'LEFT'.
      lwa_column-verticalalignment   = 'MIDDLE'.
      APPEND lwa_column TO p_column_definitions.
    * Column 1
      CLEAR lwa_column.
      lwa_column-columnname          = 'TAB2'.
      lwa_column-title               = 'Column 2'.
      lwa_column-tooltipheader       = 'Tooltip Column 2'.
      lwa_column-width               = '50%'.
      lwa_column-wrapping            = 'FALSE'.
      lwa_column-horizontalalignment = 'LEFT'.
      lwa_column-verticalalignment   = 'MIDDLE'.
      APPEND lwa_column TO p_column_definitions.
    Implement the method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START and add:
      DATA: lr_tview   TYPE REF TO cl_htmlb_tableview.
      FIELD-SYMBOLS: <fs_row> LIKE LINE OF table.
      ASSIGN p_row_data_ref->* TO <fs_row>.
      CASE p_column_key.
        WHEN 'TAB1'.
          CREATE OBJECT lr_tview.
          lr_tview->id = p_cell_id.
          GET REFERENCE OF <fs_row>-tab1 INTO lr_tview->table.
          lr_tview->footervisible = ''.
          lr_tview->width = '100%'.
          p_replacement_bee = lr_tview.
        WHEN 'TAB2'.
          CREATE OBJECT lr_tview.
          lr_tview->id = p_cell_id.
          GET REFERENCE OF <fs_row>-tab2 INTO lr_tview->table.
          lr_tview->footervisible = ''.
          lr_tview->width = '100%'.
          p_replacement_bee = lr_tview.
      ENDCASE.
    With this you get a table in a table. Now if you create a second iterator you'll be able to adjust the apperance of the inner table, as well as you can add column headers.
    Hope that helps.
    Best Regards
    Michael

  • Can Data Masking support dependent column definition between instances

    Hi,
    The customer is trying to conduct an POC of Data Masking,one requirement is supporting "dependent column" definition between oracle databases.
    I know it's ok within an database,but no idea about between serveral databases.
    Do you have any advice.
    Thanks a lot.
    Kelvin

    I guess using a databaselink might do the job.
    Regards
    Rob

  • How to reduce the column definition w/o losing the data in the columns?

    I need to reduce a particular column definition of a table from varchar2(10) to varchar2(4), but there is already existing data inside this column. The max length of data in this column is only 2 chars, which is less than the new column length.
    What commands/steps should I take to reduce the column definition successfully without losing the data in this column?

    Unfortunately, there is no one step solution.
    You can create a new table and insert into this table with the old table values
    e.g.
    Old_Table
    fld1 varchar2(10)
    New_Table
    fld1 varchar2(4)
    insert into new_Table (select * from Old_Table) ;
    I need to reduce a particular column definition of a table from varchar2(10) to varchar2(4), but there is already existing data inside this column. The max length of data in this column is only 2 chars, which is less than the new column length.
    What commands/steps should I take to reduce the column definition successfully without losing the data in this column?

  • Listing foreign keys with non matching column definitions

    Dear All,
    I seen an entry in DBA weeky activities s that "Listing foreign keys with non matching column definitions" . What is meant by that?. How to pick up that?
    Shiju

    I seen an entry in DBA weeky activities s that
    "Listing foreign keys with non matching column
    definitions" . What is meant by that?. How to pick up
    that?Most probably find columns which are part of foreign keys, but their respective primary key column have different length (AFAIK data type cannot be different).
    Data dictionary can help you in that, I'll give you hints where to look at:
    user/all/dba_constraints - foreign and primary keys
    user/all/dba_cons_columns - columns which are part of constraints
    user/all/dba_tab_columns - column definitions of tables
    However creating query from these data dictionary views could be a nice task for you :)
    Gints Plivna
    http://www.gplivna.eu

  • Column definition for a specific column in a view

    Is there a way to query the metadata to get the definition of a single column in a view? I can see the complete DDL for a view from USER_VIEWS.TEXT, and I can see the column listing in USER_TAB_COLUMNS to give the datatype etc. However, what I'm looking for is the DDL that defined a specific column.
    So, given:
    create table PERSON (
    SSN VARCHAR2(12),
    FIRST_NAME VARCHAR2(25),
    LAST_NAME VARCHAR2(25),
    STREET VARCHAR2(40),
    CITY VARCHAR2(30),
    STATE VARCHAR2(30),
    ZIP VARCHAR2(15),
    COUNTRY VARCHAR2(35))
    create view PERSON_VW as
    select SSN,
    FIRST_NAME,
    LAST_NAME,
    FIRST_NAME || ' ' || LAST_NAME FULL_NAME
    from PERSON
    I expect the query might look something like:
    select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FULL_NAME'
    and the result would be: "PERSON.FIRST_NAME || ' ' || PERSON.LAST_NAME"
    or select DDL from metadata where table_name = 'PERSON_VW' and column_name = 'FIRST_NAME'
    and the result would be: "PERSON.FIRST_NAME"
    Thanks!

    >
    Hi again Barry,
    When I queried user_tab_columns (or dba_tab_columns or all_tab_columns), I have the following list of columns:
    TABLE_NAME
    COLUMN_NAME
    DATA_TYPE
    DATA_LENGTH
    DATA_PRECISION
    DATA_SCALE
    NULLABLE
    COLUMN_ID
    DEFAULT_LENGTH
    DATA_DEFAULT
    I don't see anything resembling the DDL for the view column. Somewhere underneath some
    cover I haven't peeked under, Oracle must be keeping track of what it is supposed to be giving
    for, in my example, FULL_NAME.Unless I'm very much mistaken, these columns' data (per table) looks pretty much like DDL to me.
    Maybe what you need is just SQL Developer (great tool, if you don't have it, get it!).
    And it's free (as in beer - not as in speech! :( )
    Beside the connections tab is a "Reports" tab with various, as you might expect ;), reports.
    One of them is on the Tables - with (some) DDL. This will work as a once-off if that's what
    you need?
    Otherwise there's the SQL tab if you open a table under connections - it's very complete - sample
    at bottom of post.
    HTH,
    Paul...
    (Ultimately, I'm diagnosing problems in existing databases that have views already created so
    I don't have the option of considering virtual columns.)Quelle surprise ;(
    Paul...
    -Barry
    CREATE TABLE "HR"."COUNTRIES"
        "COUNTRY_ID"   CHAR(2 BYTE) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE,
        "COUNTRY_NAME" VARCHAR2(40 BYTE),
        "REGION_ID"    NUMBER,
        CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE,
        CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE
      ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING STORAGE
        INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
      TABLESPACE "USERS" PCTTHRESHOLD 50;
    COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_ID"
    IS
      'Primary key of countries table.';
      COMMENT ON COLUMN "HR"."COUNTRIES"."COUNTRY_NAME"
    IS
      'Country name';
      COMMENT ON COLUMN "HR"."COUNTRIES"."REGION_ID"
    IS
      'Region ID for the country. Foreign key to region_id column in the departments table.';
      COMMENT ON TABLE "HR"."COUNTRIES"
    IS
      'country table. Contains 25 rows. References with locations table.';

  • Usage Tracking table column definition

    Hi Gurus,
    I am not able to visualize the difference / significance of these two columns in S_NQ_ACCT table for usage tracking:
    NUM_CACHE_HITS - {Indicates the number of times existing cache was returned.}
    NUM_CACHE_INSERTED - {Indicates the number of times query generated cache was returned.}
    i got NUM_CACHE_HITS which gives the number of times cache match has occured, but what is role / meaning of NUM_CACHE_INSERTED, the documentation says "Indicates the number of times query generated cache was returned" what is query generated cache?
    Thanks,
    Sri

    hi jups,
    By deafult that parameter wil be null ,but any query got cached then it updates its value this way num_cache_inserted = 1
    Will this help you Definitions of time-related fields of usage tracking data
    hope helps you.
    Cheers,
    KK

  • 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

  • Shortly column definition

    This is a biggest stupid question, but...
    I would like to create a funtion that return a "field" for to put a column into a select. I will explian with an example:
    my field (that usually write into a select):
    NVL(ROUND(SUM(DECODE(field1,0,DECODE(field2,'T',myfield)))),0)
    So, my problem is that I have a lot of this field and I would like to create a function for to have a shortly select command
    for example, starting from:
    SELECT
    NVL(ROUND(SUM(DECODE(field1,0,DECODE(field2,'T',myfield1)))),0)
    NVL(ROUND(SUM(DECODE(field1,0,DECODE(field2,'T',myfield2)))),0)
    NVL(ROUND(SUM(DECODE(field1,0,DECODE(field2,'T',myfield3)))),0)
    FROM TABLE1, TABLE2
    WHERE
    join TABLE1 with TABLE2
    I would like to arrive to:
    SELECT myfunction(myfield1), myfunction(myfield2), myfunction(myfield3)
    I will create a function that return a string for to put it into the select or there is another solution for to have the myfield really that can be correctly calculated into the SELECT command ??
    thanks in advance for your help and best regards.
    Roberto

    You don't make quite clear where these fields come from (tables have columns, forms have fields) but you could do something like this:
    SQL> r
      1  CREATE OR REPLACE FUNCTION my_function (p1 IN VARCHAR2, p2 IN VARCHAR2)
      2     RETURN NUMBER
      3  AS
      4     default_value CONSTANT NUMBER := 999;
      5     return_value NUMBER;
      6  BEGIN
      7     IF p1 IS NULL
      8     THEN
      9        return_value := 0;
    10     ELSIF p1 = 0
    11     THEN
    12        IF p2 = 'T'
    13        THEN
    14           return_value := default_value;
    15        ELSE
    16           return_value := p2;
    17        END IF;
    18     ELSE
    19        return_value := p1;
    20     END IF;
    21     RETURN round(return_value);
    22* END my_function;
    Function created.
    SQL> select sum(my_function( col1, col2)) FROM t1
      2  /
    SUM(MY_FUNCTION(COL1,COL2))
                             21
    SQL> Note that you cannot write aggregating functions, so you have to use SUM in the select statement.
    Two additional points:
    [list]
    [*]If you are using 8i you don't need to declare the RESTRICT_REFERENCES pragma.
    [*]If you want to do dataconversion with this thing it might be worth looking at the CREATE OPERTATOR functionality to create an overloaded function.
    [list]
    Cheers, APC

Maybe you are looking for

  • Cant find iphoto library

    My 1 year old was playing w/ my keyboard and I think accidentally erased Iphoto. The icon is still on the toolbar, but when I click on it I get a message saying "iPhoto can't continue without a Photo Library. Make sure the disk containing your Photo

  • Vendor article No.

    Dear all, There is a vendor article no. in article master/ material info record which can link  the our material no. and the product code assigned by vendor. If we have maintained this vendor article no. in master record,  should we enter this no. di

  • Sound Issues with K8N Neo4 Platinum

    Over the last few days I've not been able to get any sound through the onboard line out socket in my pc. I only built it 2 weeks ago and havent noticed until the other day when I first used speakers. So for about 3 days now I've gone through ALL of t

  • SYSTEM-ERROR. Tokens: MESSAGE = Io exception: NL Exception was generated;

    Hello, When I am running a page in jdev, I am getting the following error: NVFactory: _readNVPair expected ) NVFactory: _readNVPair expected ) NVFactory: _readNVPair expected ) NVFactory: _readNVPair expected ) oracle.apps.fnd.framework.OAException:

  • Music Files are skipping

    Hi, I recently purchased the iPod classic (80G). Previously i had the iPod before. It seems now that a lot of my music skips either back to the beggining or to the next track about 20-30 secs through the track. i Read on here that the way to combat t