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

Similar Messages

  • Join on ambiguous column name

    I have three tables I am working with. employee_passenger, nonemployee_passenger, employee (linked from another database). I want to outer join the passenger tables on the employee table for a view I am creating. Can I alias the two passenger tables and generically outer join both in one statement?
    Example:
    SELECT p.pk_passenger_id "Passenger_ID", n.pk_passenger_id "Passenger_ID", e.emp_id
    FROM employee_passenger p, nonemployee_passenger n, employee@somewhere e
    WHERE Passenger_ID = e.emp_id (+)
    Desired result:
    Passenger_ID Passenger_ID emp_id
    101 9230
    102
    103 9249
    Or would it be better to do something like:
    SELECT p.pk_passenger_id, n.pk_passenger_id, e.emp_id
    FROM employee_passenger p, nonemployee_passenger n, employee@somewhere e
    WHERE p.pk_passenger_id IS NULL OR p.pk_passenger_id = e.emp_id

    Consider the following approach:
    First union both passenger tables, then join with the emp table (not tested).
    SELECT p.pk_passenger_id Passenger_ID, e.emp_id, p.sourcetable
    FROM (SELECT 'E' sourcetable, pk_passenger_id
               FROM employee_passenger
               UNION ALL
               SELECT 'NE' sourcetable, pk_passenger_id
               FROM nonemployee_passenger
               ) p,
               employee@somewhere e
    WHERE p.pk_Passenger_ID = e.emp_id (+)

  • Same column name from different table

    i have a sql query as like this : "SELECT * FROM TABLE1,TABLE2". i use oracle. both TABLE1 and TABLE2 have the same column named 'COLUMN1'. while i get rows how i know the value of COLUMN1 from which table (TABLE1 or TABLE2).
    sample code snippet is above. do u help me!
    while (rs.next())
    value1 = rs.getString("COLUMN1");
    // is value1's value from table1 or table2. how do i know this?
    // i try value1 = rs.getString("TABLE1.COLUMN1"); but it doesn't work :(
    ....

    I case you don't know what an alias is, it would look something like this:
    SELECT a.COLUMN1 as FirstColumn1, b.COLUMN1 as SecondColumn1 FROM FirstTable a, SecondTable b
    Notice that in the FROM clause we've appended a short name for each table. You're not limited to one character, but I try to keep it simple. Now we can refer to the tables as a and b.
    Because I did that I have to refer to any ambiguous columns (although it's good practice to refer to ALL columns) using the table name prefix and a period. This tells the driver which "COLUMN1" I want. Then we include as AS clause which allows us to tell the driver what we want that column name to be when it's returned to us. This is specially usefule when I have two columns in two separate tables with the same name (as you have here) or if I'm calculating data (i.e. (a.QTY * b.PRICE) as UnitPrice) that doesn't have a column name, so here I can give it one.
    It's a little weird at first since you use the alias names in the select before you actually define them in the FROM clause, but you'll get use to it.
    Now you retrieve FirstColumn1 and SecondColumn1 from your ResultSet, not Column1.
    HTH.

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

  • Referencing table-aliased column names in JDBC

    We are attempting to port an application from MySQL to Oracle 8i, using JDBC as the database connection technology. The app has SQL statements using joins, e.g.
    SELECT A.*, B.* FROM table1 A, table2 B WHERE A.field1=B.field2 etc
    Often the tables have columns sharing the same name, so the table alias is required to avoid ambiguity (e.g. both tables have column ID, so they must be referenced as A.ID or B.ID).
    When using MySQL, the Java code
    String strField = rset.getString( "SURNAME" );
    or
    String strField = rset.getString( "A.SURNAME" );
    both succeed if the column name is unique, and if it is not unique, only the second form works. However, with Oracle, the second form never works, even though the column name is a valid column in the table aliased as A. Providing the whole table name does not work either:
    String strField = rset.getString( "table1.SURNAME" );
    If the Oracle JDBC driver does not support the {table-alias}.{column-name} syntax, then presumably the only way to reference ambiguous columns in joins is to supply the column number instead. (e.g. getString( 14 )). Our application generates dynamic SQL, and having to do this would be a MAJOR problem.
    We are currently using Oracle 8i - might this have been fixed in the move to 9i?
    Many thanks for any help,
    Steve Francis,
    London, UK.

    Can't do it by alias, as you would just repeat the
    calculation/function/whatever and add whatever additional "stuff"
    to create your new column.
    ISNULL(row1, 99999) AS ideal,
    ISNULL(row1, 99999)+10 AS newideal
    etc.
    Phil

  • Invalid column name for the group attribute.

    Hi,
    Please help, I m struck with this for the past 2 days.
    Basically i have  big query and with cfoutput and group attribute; i m displaying hte results..
    It has 4 levels of grouping.
    Also, the grouping column will be different every time the user choose it.so I'm building an array to do it.
    Suppose the user choose only 3 columns, I'm manually adding the 4th column so that array has 4 values all the time.
    At time, i m getting this error, the column name is invalid.
    Your help is highly appreciated.
    <cfoutput query="mtburbycust" group="#lstSQLOrderBy[1]#">
              <cfif currentRow EQ 1>
                  <cfset rowColor2 = 'CECE9E'/>
             <cfelse>
                 <cfif isdefined('Prevcolor')>
                    <cfif comparenocase(Prevcolor,rowColor3) EQ 0>
                        <cfset rowColor2 = 'A8E4FF'/>
                    <cfelse>
                        <cfset rowColor2 = 'CECE9E'/>
                    </cfif>
                </cfif>
              </cfif>
              <cfset Rowcolor = Rowcolor2/>
               <cfset Prevcolor = Rowcolor2/>
             <cfoutput group="#lstSQLOrderBy[2]#">       
                  <cfoutput group="#lstSQLOrderBy[3]#">
                <cfoutput group="#lstSQLOrderBy[4]#">    
                   <cfoutput>
    </cfoutput>
    </cfoutput>
                        </cfoutput>
                    </cfoutput>
                </cfoutput>
            </cfoutput>

    These tags are somewhat ambiguous, as they have no query attribute:
    <cfoutput group="#lstSQLOrderBy[2]#"> 
    <cfoutput group="#lstSQLOrderBy[3]#">
    <cfoutput group="#lstSQLOrderBy[4]#">

  • How to Select data using same column name from 3 remote database

    Hi,
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
    Ex.
    SELECT *
    a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
    FROM
    *((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
    *(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
    WHERE b.dept = 'finance'
    AND a.position = 'admin'
    AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
    GROUP BY a.name, b.status ;
    NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
    Thanks in advnce. :)
    Edited by: user12994685 on Jan 4, 2011 9:42 PM

    user12994685 wrote:
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
    Each object must be uniquely identified. So you cannot do this:
    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
    ERROR at line 1:
    ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
    ERROR at line 1:
    ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    DUM DUM
    X   X
    SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution.

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

  • How to rename C00n generic column names in a Dynamic SQL report

    I have a an interface whereby the user can select 1 to 60 (upper limit) columns out of 90 possible columns (using a shuttle) from one table before running a report.
    To construct the SQL that will eventually execute, I'm using a "PLSQL function body returning SQL query" with dynamic SQL. The only problem is that I have to use "Generic Column Names" option to be able to compile the code and end up with c001 to c060 as the column names.
    How can I use the names of the selected columns as the report headings rather than c001, C002... etc?
    I do not know beforehand which columns, or how many columns or the order of the selected columns.
    I know Denes K has a demo called Pick Columns but I can't access his code. I have a hunch though that he may be just using conditions to hide/show the apropriate columns.
    thanks in advance
    PaulP

    Hi Paul
    I would change the Heading Type in the Report Details screen to PLSQL and use the shuttle item to return the column values. e.g.
    RETURN :p1_shuttle;
    I'm assuming the shuttle already has a colon separated list of the column headings in the correct order?
    I hope that helps
    Shunt

  • Reading MS Project column names and data on the fly from a selected View

    Hi guys,
    I have several views on my project file (MSPROJECT 2010) and I want to build a macro so that;
    1. User can select any view ( Views can have diffrent columns and the user may add new columns as well)
    2. User runs the Macro and all the coulmns along with the tasks displayed in the view will be written to a excel file. ( I don't want to build several macro's for each view, I'm thinking of a common method which would work for any selected view)
    The problem I'm facing is that how will i read the column names and data for a particular view on the fly without hard coding them inside the vba code ?
    The solution needs to work on a master schedule as well.
    Appreciate your feedback.

    Just to get you started the following code writes the field name and data for the active task to the Immediate window.
    Sub CopyData()
    Dim fld As TableField
    For Each fld In ActiveProject.TaskTables(ActiveProject.CurrentTable).TableFields
    If fld.Field >= 0 Then
    Debug.Print Application.FieldConstantToFieldName(fld.Field), ActiveCell.Task.GetField(fld.Field)
    End If
    Next fld
    End Sub
    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

  • Oracle 10g - Defining the column name in Non English

    Hi Experts,
    I have an exisitng application which is developed on Windows using ASP Technology and uses Oracle 10g 10.1.0.2.0.
    The application is supported with an instance of Data Base within which multiple tablespaces are created for different clients. The application is developed in such a way that some of the tables arecreated dynamically and the columns are named using the data entered through the UI.
    This application needs to be globalized now. The problem is, the column name entered through the UI can be in any language based on the client's settings and those values in turn will be used for naming the columns in the tables.
    1) Can I have the column names to be named using non english characters in Oracle 10g DB? If so,
    1.1) what should I do to configure the exisiting Oracle instance to support it?
    1.2) To what level is that configuration possible, is it per DB instance level (or) can it be done at Tablespace level. I would like to configure each tablespace to host tables with columns defined with different languages, say for example, tablespace 1 will have tables with Japaenese column names and tablespace 2 will have tables with German column names?
    2) What should I do to make my entire DB to support unicode data i.e., to accept any language strings. Currently all strings are declared as VarChar2, should I change all VarChar2 to NVarChar2 (or) is there a way to retain the VarChar2 as is and make some database wide setting?
    Please note that I do not have an option of retaining the column in English as per the Business Requirement.
    Envionment:
    OS - Windows 2003 32 bit
    Oracle 10g 10.1.0.2.0
    UI forms in ASP
    TIA,
    Prem

    1. Yes, you can.
    SQL> create table ÜÝÞ( ßàá number(10));
    Table created.
    SQL> insert into ÜÝÞ values (10);
    1 row created.1.1 and 1.2 and 2. You can choose UTF as your default character set. It allows the user of non-English characters in VARCHAR columns in your whole database. It is not per tablespace.
    SQL> create table ÜÝÞ( ßàá varchar2(100));
    Table created.
    SQL> insert into ÜÝÞ values ('âãäçìé');
    1 row created.

  • What is the order of Column Names in Sqlite query results?

    I am writing an application using Adobe Air, Sqlite, and Javascript.
    After writing the following select statement:
              SELECT field1, field 2, field 3, field 4 FROM TableA;
    I would like to get the columnName/data combination from each row -- which I do successfully with a loop:
              var columnName="";
              for (columnName in selResults.data[i]) {
                   output+=columnName + ":" + selResultsdata[i][columnName] + ";";
    My issue is that the column names come out in a different order every time I run the query and never once have they come out in the desired order -- field 1, field 2, field 3, field 4.  If I run the query in Firefox's Sqlite Manager, the columns come out in the "proper" order. When I run them in Adobe Air, the order will be the same if I run the query mulitple times without closing the app.  If I make a change such as declaring the columnName variable with "" before the for column, or declare it as (var = columnName in selResults.data) , then the order changes.  If I shut down my app and re-open after lunch and run query, it comes out in another order.  At this time, I'm not interested in the order of the rows, just the order of the columns in each output row.  I've even tried assiging an index to columnName which seems to just pick up a single letter of the columnName.
    I'm in the process of changing my HTML presentation of the data to assign a precise columnName to an HTML table title, but I'm reluctant to let go of the above concept as I think my separation of HTML/presentation and Javascript would be better if I could use the solution described above.
    So, does anybody know how to force the order of the columnNames in my output -- or what I'm doing to cause it to come out in a different order?
    Jeane

    Technically there isn't any "order" for the return columns. They aren't returned as an Array -- they're just properties on an Object instance (a "generic object"). The random order you're seeing is the behavior of the for..in loop iterating over the properties of the object. Unfortunately, with a for..in loop there is no guaranteed order for iterating over properties (and, as you've seen, it tends to vary wildly).
    The only solution is to create your own list of the column names and sort it the way you want to, then use that to create your output. For example, use the for..in loop to loop over the properties, but rather than actually get the values, just dump the column names into an Array:
    var columnName="";
    var columns = [];
    for (columnName in selResults.data[i]) {
        columns.push(columnName);
    columns = columns.sort(); // just uses the default alphabetical sort -- you would customize this if desired
    var j = 0;
    for (j = 0; j < columns.length; j++) {
        columnName = columns[j];
        output+=columnName + ":" + selResultsdata[i][columnName] + ";";

  • Can we use Column Names in Parameter Cursor

    Hi
    can we use Column Names in Parameter Cursor??
    DECLARE
    CURSOR Emp_Cur (P_Deptno NUMBER)
    IS
    SELECT Empno, Ename
    FROM Emp
    WHERE Deptno = P_Deptno;
    BEGIN
    FOR Emp IN Emp_Cur(10)
    LOOP
    DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
    DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
    END LOOP;
    FOR Emp IN Emp_Cur(20)
    LOOP
    DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
    DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
    END LOOP;
    END;
    In the above Program, I send Deptnumber. If i send Column names like Empno, Ename. What can i do??
    If Declare Samething Through Parameter Cursor, it doesn't accept VARCHAR2(Size)

    For parameters you don't use size, just the type (DATE, NUMBER, VARCHAR2, CLOB, ...)
    DECLARE
      CURSOR Emp_Cur (P_Ename VARCHAR2)
      IS
        SELECT Empno, Ename
        FROM Emp
        WHERE Ename = P_Ename;
    BEGIN
      FOR Emp IN Emp_Cur('SCOTT')
      LOOP
        DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
        DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
      END LOOP;
    END;

  • Can I use bind variable instaed of writing static COLUMN Name

    Hi , I am having a table containing id and column names, the data is stored against that id in other tables. Now I wish to update data into another table so that it goes into apppropriate column without using decode function.
    I am trying to do this:
    EXECUTE IMMEDIATE 'update TEST set :1 = :2
    where PROJECT_ID= :3 and UNIQUE_ID= :4' using P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID;
    the values P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID are populated using a cursor in PL/SQl
    Is this statement valid? If not can you tell me how to do it as I am getting some error I am unable to comprehend.
    thanks
    Rishabh

    Column names cannot be substituted at run-time as bind variables. If you need to specify the column name at run-time, you'd need to construct a new string and execute that string dynamically, i.e.
    EXECUTE IMMEDIATE 'UPDATE test SET ' || p_dest_column || ' = :1 ' || ...From a data model standpoint, storing column names as data elements in another table is generally a rather poor idea. It's likely to make ad-hoc reporting nearly impossible and to cause a lot more parsing than would otherwise be required.
    Justin

  • Need help on getting the column names of Tabletype

    I have a table Mapping with the following values: This Mapping table contains the table names (in Tabname) and the column names(colname) of various tables and values(ValuesTobeFilled) for the columns.
    I have to insert into the tables present in the Tabname field with the values present in the ValuesTobeFilled in the columns present in the Colname field.
    Note: The Mapping table need not contain all the columns of the base table. The columns that are not present can be filled with null. And this mapping table is not fixed i.e. rows can be inserted/deleted frequently.
    Sample values in mapping table:
    Tabname                        Colname        ValuesTobeFilled
    sample_items     Eno     Corresponding Expression to get the values from XML input
    sample_items     Ename     Corresponding Expression to get the values from XML input
    XXX     YYY     Corresponding Expression to get the values from XML input
    Before filling in the actual tables, I have to store the entire data temporarily and I have used a tabletype declared as follows:
    TYPE T_sample_items IS TABLE OF sample_items%ROWTYPE INDEX BY BINARY_INTEGER;
    l_sample_items T_sample_items;
    Where the table sample_items have the following columns:
    •     Eno
    •     Ename
    •     Eaddress
    •     Eemail
    So, the tabletype should be filled as:
    Eno     Ename     Eaddress     EEmail
    1     XXX     -     -
    I have declared a cursor to select the values from mapping table and I need to fill in the ValuesTobeFilled values to the corresponding table.
    CURSOR c_xpath (c_tname mapping.TABNAME%type)
    IS
    select * from mapping where tabname = c_tname;
    CURSOR c_tables
    IS
    SELECT DISTINCT TABNAME FROM mapping;
    FOR crsr IN c_tables
    LOOP
    p_tname := CRSR.TABNAME;
    FOR csr IN c_xpath(p_tname)
    LOOP
    IF l_xml_doc.EXISTSNODE(CSR.XPATH_EXP) = 1
    THEN
    l_node_value := l_xml_doc.extract(CSR.XPATH_EXP).getStringVal(); -- This is the value to be stored in the corresponding column
    ELSE
         l_node_value := NULL;
    END IF;
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).name := l_node_value;
    END IF;
    END LOOP;
    END LOOP;      
    And I need to eliminate hard coding while comparing the column names (in the following piece of code) as the Mapping table values are subject to insertion/deletion:
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).ename := l_node_value;
    END IF;
    I need to insert the values directly into the tabletype without this hardcoding. Please suggest me ways to compare the mapping table values with the field (column) names of the tabletype. If it is not possible using tabletype, please suggest any other ways of fixing the problem.
    Many thanks,
    Gopi

    I take it this isn't going to be a serious production system at the end of the day?
    Storing metadata in tables for extraction and insertion of data is just wrong in so many ways. It smells heavily of Entity Attribute Value modelling, which is the most wrong way to use a relational database and is known to have major performance implications and be liable to bugs and issues. The idea that EAV modelling allows for 'generic' databases where new data items can be added flexibly later on without having to change code is usually justified with an excuse of "it means we don't have to update all our tables when we want a new column" which is easily countered with "if you're adding a single column a good relational design wouldn't require you to add it to more than one table anyway in most cases".
    Just what exactly are you trying to do and why? There has to be a better way.

Maybe you are looking for