External table with mixed columns

Hello everyone. We use Oracle 11R1. We have an external table pointing to a CSV with 7 columns inside. The file has always column 7 but the column order differs from time to time. Each column has a header that remains consistent. Is there a way to map the column names to the column header, s so that we did not change the definition of the external table every time a new file is available in?

Thank you.

Hello

As John said, you must assign names of columns when the table is created.  I guess you could have a dynamic SQL solution that reads the header you mentioned, uses this information to write a CREATE table, drop the table, and then recreated with the new order of the columns.

You may have a view that maps the 7 columns in your table of 7 columns in the view.  Which column gets the mapping to that may depend on the header.

Tags: Database

Similar Questions

  • external table with preprocessor option

    Hello!

    Can someone help me, I created an external table with option of preprocessor, but error encountered when querying the external table below.

    I use Version 2.1.0.63 oracle sql developer.
    I run the query on my client.
    My files are under the oracle database server (version is 11.1.0.6).
    Linux operating system.

    Error report:
    SQL error: ORA-29913: error in executing ODCIEXTTABLEOPEN legend
    ORA-29400: data cartridge error
    KUP-00554: error occurred when parsing the access settings
    KUP-01005: syntax error: found 'distinctive sign': expected an a: "badfile, bigEndian, characterset, column, data, delimited, discardfile, disable_directory_link_check, fields, set, load, logfile, language, nodiscardfile, nobadfile, nologfile, date_cache, transformation, TailleLue, chain, skip, territory, variable.
    KUP-01008: the bad ID was: PREPROCESSOR
    KUP-01007: in column 10 on line 2
    29913 00000 - "error in the execution of %s legend".
    * Cause: The execution of the specified legend caused an error.
    * Action: Examine the error messages take appropriate measures.

    Upgrades the database to 11.1.0.7 the only way to solve this problem?


    Thank you!
    Dhekz

    You need version 11.2 database...

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e10881/Chapter1.htm#NEWFTCH1
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e10595/tables013.htm#ADMIN12898

  • Gears - error when you try to insert values into a table with multiple columns

    Hello

    I started playing with the gears and SQlLite today and I get an error when I try to insert values into a table with multiple columns.

    I have:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text, DeveloperAge int)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?, ?)', [devName, devAge]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I get the error:

    net.rim.device.api.database.DatabaseException; insert into developers values (?,?): SQL logic error or missing database.

    I use this reference: http://code.google.com/apis/gears/api_database.html

    Everything works if I have only one field as:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?)', [devName]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I use the plug-in Visual Studio 2.0 for 2008 that are running Windows XP SP and Simulator 2.13.0.56

    Thank you

    Davy

    Yes, a SQLite database will persist between battery pulls.  The database is registered either to internal MEM or removable media (not the device memory), depending on which is available on your device.

    In general, its not considered a best practice to remove your table as soon as it is empty and re - create it again when you want to add data.  This adds extra overhead fresh for the final, delete and insert first for a given table.  Instead, define and finalize your drawing before you create your table.  Once created, review the static schema.

    That being said, for development purposes, it may be easier to provide an easy way to drop your tables while you develop your schema.

    See you soon,.

    Adam

  • Export an ADF table with default column order

    Hello

    Jdev 11.1.1.5.0

    We have ADF Table with column drag and drop option. Also we have implemented ADF Table with excelHTMl type of export.

    Everything works as expected. Only problem is if we try to exchange a few columns by drag-and - drop option and then export the table, we receive the order of the columns with brewing. But our demand is, the user must obtain the export with the initial order table by default.

    It would be great, if you can suggest an idea to export the ADF table with default column order.

    Thanks in advance,

    MSR.

    I realized the required functionality. We can restore the default order of the columns to aid

       Function richeTableau = this.getFetchResultsTable ();
       Iterator rItr = rTable.getChildren () .iterator ();
       {while (rItr.hasNext ())}
           ((RichColumn) rItr.next ()).setDisplayIndex(-1);
       }

    Then we can call the real export help feature

       queue the event via a JavaScript inserted into the page
       FacesContext context = FacesContext.getCurrentInstance ();
       Erks = ExtendedRenderKitService
       Service.getService (context.getRenderKit (), ExtendedRenderKitService.class);
       erks.addScript (context, "customHandler()");
  • External table with the preprocessor file to display the list of files

    Hello

    in my db 11.2.0.2 I would create an external table with script preprocessor to show me the list of files in a directory.

    Preprocessor banally:

    #! / bin/bash

    CD/MyDir

    / bin/ls-l *.txt 2 >/dev/null

    The problem is the file name that contains white space (style windows in a Linux env), for ex:

    -rw - r - r - 1 oracle oinstall 920 9 Jun 17:37 File1.txt

    -rw - r - r - 1 oracle oinstall 72316 Jun 10 10:37 file GC output1.txt

    -rw - r - r - 1 oracle oinstall 72316 Jun 10 10:40 GC file output2.txt

    So I can't use FIELDS DELIMITED BY "". ""

    FIXED size? No, because the file size change the length of the lines.

    I tried to use awk in my preprocessos script, but I have the same problem:


    / bin/ls-l *.txt 2 >/dev/null | / bin/awk ' {printf "%s %.2d %s %s\n", $6, $ 7, $ 8, $9} '.


    Any ideas?

    Hello

    I used java to retrieve information about the files.

  • Declare a type of table with multiple columns

    I have a table with a column of type, and I want to create one with two columns.

    My type is:
    create or replace type "NUMBER_TABLE" in the table of the number;

    And I use it in function:

    FUNCTION GetValues()
    return NUMBER_TABLE
    as
    results NUMBER_TABLE: = NUMBER_TABLE();
    Start
    Select OrderId bulk collect in: results from (select * from tbl_orders);
    -Other code...
    end;

    I want select it be like this:
    Select OrderId, OrderAddress bulk collect into: results from (select * from tbl_orders);

    How to do this?

    Is that what you are looking for:

    CREATE OR REPLACE TYPE two_col_rec AS OBJECT (empno NUMBER, ename VARCHAR2(10))
    /
    
    CREATE OR REPLACE TYPE two_col_table AS TABLE OF two_col;
    /
    
    CREATE OR REPLACE FUNCTION GetValues RETURN two_col_table AS
       results two_col_table := two_col_table();
    BEGIN
       SELECT two_col(empno, ename) BULK COLLECT INTO results FROM emp;
       --
       RETURN results;
    END;
    /
    show errors
    
  • Fill a table with two columns using a custom bean

    Hello

    Can you provide me or give me a link to an example of populating a table (with two columns) with a custom bean?

    Thank you

    TSPS

    Hello..
    I'm Jules Destrooper is what you want

    http://download.Oracle.com/docs/CD/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

    Hopes, will help you

  • How to create a table with editable column values.

    Hello world
    I think it's very simple, but I am unable to find how to do this. This is my requirement. I need to create a table with n columns and 1 line initially. the user must be able to enter data into this table and click of a button must insert the data into the database table. Also, there should be a button at the bottom of the table to add 1 line to the table.

    I know how to do the insertion of data, but can someone please let me know how to create a table which allows the user to enter data and how to create a line button Add 1?


    Thanks in advance!

    Raghu,

    Go through the tutorial of Toolbox Page & Advanced section of the Guide of the OFA table.

    Step 1 - you need to create EO & VO from this EO. This EO will be table of database where you want to insert the data.

    Step 2 - create an advanced table region. (See this section in table advanced for more details)

    Step 3 - attach this VO in the BC4J region advanced Table component.

    Kind regards
    GYAN

  • Unique table with several columns or several tables split?

    What is the best.

    A table with multiple columns inside or divided into several tables. Why?
    How will the performance in the two scenarios?

    Hello

    user13024762 wrote:
    I have a table EMP that has column EMP_ID, EMP_NAME MGR_ID, MGR_NAME, SALARY, EXP_IN_MNTHS, EXP_IN_YRS... etc with multiple columns

    I have the following tables
    EMP-> EMP_ID, EMP_NAME

    Each row in the table emp thie represents a separate employee. I guess other columns in the emp table might be birth_date, social_security_number and status (by example, 'Active', 'Leave', 'complete'). Here's what an employee has (at least) one of. If there is a one-to-many relationship between an employee and an attribute, then you probably want another table for this attribute.

    BISHOP-> EMP_ID, MGR_ID, MGR_NAME

    There is a one-to-many relationship between employees and managers? In other words, an employee may have 2 or more managers? If Yes, then you need another table.
    If there is only a one-to-one relationship between employees and managers (in other words, if an employee is never more than 1 Manager) so why don't you just have a mgr_id column in the emp table?
    Managers are also used for? (This is often the case, as in scott.emp and hr.employees.) If so, do not store their names in the EME and tables of mgr. Store name (and date of birth and other information) in the table emp only and, if you need a table of Bishop, just the emp_id and mgr_id column.

    SAL-> EMP_ID, SALARY

    There is a one-to-many relationship between the employees and wages? In other words, an employee may have 2 or more treatments? If so, how will you use the values? Is a special treatments in some way, as it will be used more often than others? (In other words, you may have a current and past wages salary, but the last wages are rarely used.)
    If you never have more than 1 salary for a given employee, why not just have a sal column in the emp table?

    EXP-> EMP_ID, EXP_IN_MNTHS, EXP_IN_YRS

    There is a one-to-many relationship between the employees and what whether you store in this table?

    etc. with more tables

    What is the best based on

    (1) performance and data recovery
    (2) ease of use
    (3) maintainability

    A one-to-many relationship requires an additional table. If an employee can have up to 3 managers, don't have mgr1, mgr2 and mgr3 columns in the emp table. Use a separate table, with up to 3 lines for the same employee, instead.
    For 1-1 relationships, it is usually best to not have separate tables.

  • can bind us a single external table with multiple files in OWB 11 g?

    Hello

    I wanted to ask if it is possible to link an external table with several source files in same or different places? Or an external table must be bound to a single source file and one place.

    Thanks in advance,
    Ann.

    Published by: Ann on October 8, 2010 09:38

    Hello Ann,.

    Can you please help me by telling me the steps to achieve this.

    Right-click on the external table in the project tree, from the menu choose Configure.
    then open right clock the node data files dialog Configuration properties and choose from the menu - Create
    you will get a new record for the file - name of file data property

    Also the link of the OWB user guide
    http://download.Oracle.com/docs/CD/B28359_01/OWB.111/b31278/ref_def_flatfiles.htm#i1126304

    Kind regards
    Oleg

  • Table with 300 columns

    While talking with a friend, he told me that sometimes he uses tables with 300 columns that will be available only once for the extraction of information. For me, it's a little strange because 300 columns looks like a large number of columns for me...

    Have tables with columns as is common practice in the data warehouse? If Yes, can you explain to me on what situations, this can happen and how often?

    Concerning

    We have tables with columns of cca 150.

    You should know that we don't talk to relational systems which are standardized. Its common practice when building data warehouse. Number of columns in the tables will depend on the complexity and the size of your warehouse and the number, size and complexity of your source systems.

    Point is that even now, when the data warehouse is "done", we still add/remove columns changes to warehouse such as changing the source systems.

  • GetLength errors on CLOB. Retrieves the size of a table with CLOB columns

    Hello

    I try to find the size of a CLOB to a table column and get the error

    PLS-00306: wrong number or types of arguments in the call to "GETLENGTH.

    When you try to use dbms_lob.getlength. Here is the code


    declare
    number num.
    Start
    for rec in (select xmlupload from FILE_TABLE where file_table_id = 33635) loop
    NUM: = dbms_lob.getLength (rec.xmlupload);
    end loop;
    dbms_output.put_line (num);
    end;

    Database version: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi


    I'm actually trying to find the size of a table with CLOB columns, is there an easy way to do this Besides using getlength and without having to contact the Administrators (they are outsourced)?

    It works fine on my computer, the version is also 10g.

    SQL> declare
      2  num number;
      3  begin
      4  for rec in (select cntnt from ims_toms_msge where rownum<3) loop
      5  num := dbms_lob.getLength(rec.cntnt);
      6  dbms_output.put_line(num);
      7  end loop;
      8
      9  end;
     10  /
    3837
    3837
    
    PL/SQL procedure successfully completed.
    

    You should check if xmlupload is the CLOB data type.
    In addition, if you just want to get the CLOB size, you can use LENGTH() as well, you will get the same result;

    SQL>  select length(cntnt), dbms_lob.getLength(cntnt) from ims_toms_msge where rownum<2;
    
    LENGTH(CNTNT) DBMS_LOB.GETLENGTH(CNTNT)
    ------------- -------------------------
             3837                      3837
    

    Published by: PhoenixBai on September 24, 2009 13:40

  • Several flat_files through the external table with only the common columns of loading

    Hi, I have 50 flat files and each of them have some columns (fields) common and I need to load only the fields that are common to an external Table. Is any chance to do it with education unique external table. Or I need to load all flat_files at separate tables and then with the ETG and UNION load them only one table.

    If the page size for all the files are different, I think that your only option would be to define different external tables and create a view that joins all the.

    HTH
    Srini

  • External table with the field tab delimiter

    With the help of Oracle 11 g Release 2

    Here is my table create statement external:

    CREATE TABLE global.ext_a_attrib_cmt
    (   tag      VARCHAR2(255)
      , from$    VARCHAR2(255)
      , to$      VARCHAR2(255)
    )
       ORGANIZATION EXTERNAL
    (  TYPE ORACLE_LOADER
       DEFAULT DIRECTORY EXT_DATA_DIR
          ACCESS PARAMETERS
            (  RECORDS DELIMITED BY NEWLINE 
               SKIP 1
               BADFILE EXT_BAD_DIR:'a_attrib_cmt.bad'
               LOGFILE EXT_LOG_DIR:'a_attrib_cmt.log'
           --    FIELDS TERMINATED BY 0X'09' -- TAB delimited  
               FIELDS TERMINATED BY '\t'
               OPTIONALLY ENCLOSED BY "'"
               MISSING FIELD VALUES ARE NULL
               REJECT ROWS WITH ALL NULL FIELDS
            )
          LOCATION ('a_attrib_cmt.txt')
    )
       REJECT LIMIT UNLIMITED
       NOMONITORING
    /
    

    Here is the text file, a_attrib_cmt.txt:

    tagOfTO
    FrontSpringType_idCoilw/FRONT COIL SPRINGS
    FrontSpringType_idSheetthe FRONT/w suspension SPRINGS
    Aspiration_idNaturally aspiratedw/o TURBO
    Aspiration_idTurbochargedw/TURBO
    Aspiration_idSuperchargedw/COMPRESSOR
    SteeringType_idGridw/RACK and PINION STEERING
    SteeringType_idGearw/GEAR STEERING
    FuelDeliveryType_idCARBw/o FUEL INJ
    FuelDeliveryType_idFIw/FUEL INJ
    BedLength_id?" BED
    BodyNumDoors_id? DR
    BrakeSystem_idw / ? BRAKES
    FrontBrakeType_idw/FRONT? BRAKES

    PUBLIC has privileges to write to the directory EXT_DATA_DIR.

    Here is the error I get:

    Globall@ORA1 > select count (*) in the ext_a_attrib_cmt;

    Select count (*) in ext_a_attrib_cmt

    *

    ERROR on line 1:

    ORA-29913: error in executing ODCIEXTTABLEOPEN legend

    ORA-29400: data cartridge error

    KUP-00554: error occurred when parsing the access settings

    KUP-01005: syntax error: found 'minussign': expected an a: "badfile, bigEndian, characterset, column, data, delimited, discardfile,

    disable_directory_link_check, fields, fixed, charge, logfile, language, nodiscardfile, nobadfile, nologfile, date_cache, preprocessor, TailleLue, String, jump,

    territory, variable.

    KUP-01007: line 5, column 8

    Just get rid of the comment line. You cannot cave comments to create external table statement. SY.

  • Loading external Table with quotes

    I have a file with fields in the file are as TAB delimiter ~ TAB.

    Example as below:

    QM ~ CD ~ Exzm ~ BMW

    DM ~ BD ~ Exzm ~ BMW

    CREATE TABLE test

    (

    Col_1 VARCHAR2 (100),

    Col_2 VARCHAR2 (100),

    Col_3 VARCHAR2 (100),

    Col_4 VARCHAR2 (100)

    )

    EXTERNAL ORGANIZATION

    (TYPE ORACLE_LOADER

    DEFAULT DIRECTORY 'Test_Report '.

    ACCESS SETTINGS

    (records delimited by '\n'

    CHARACTERSET 'UTF8 '.

    fields terminated by '\t~\t '.

    missing field values are null

    )

    LOCATION ("test.asc")

    )

    REJECT LIMIT UNLIMITED;

    OUTPUT:

    ----------------

    Data loaded in DB, but col_4 data comes from the quotation as below

    col_4

    -------

    "BMW".

    "BMW".

    Note: Col1 - col3 data arrives correctly.

    2807064 wrote:

    A finding on my side.

    I found that the values of Col_4 after inserting into DB with "transport return character" (CHR (13)) at the end of each value as shown below when I copy paste the value in notepad ++ "»

    Example:

    ----------

    "BMW".

    "

    But if I see the file I saw that BMW.

    My question is, in this case the external table loading must fail right? Why is this it is to load data in DB?

    Do you have this file begin life on windows, and then are transferred to * nix to serve an external table?  If so, which explains a lot.  Windows is the standard record delimiter x '0d0a' (Chr (13) 10)  On * nix, it's just x '0A' (10.  When the process of loader is scanning for record delimiter he's just looking for the '0A' x and x'd 0' gets included in the data.

    Two solutions-

    1 - Make sure that the data file is transferred so that the Records delimiters are converted.  It's supposed to to happen with ascii ftp mode, but this week I saw several examples in the House of it does not.

    2. attach your table definition external to seek the delimiter of actual recording instead of the default value of the operating system. == RECORDS DELIMITED BY X '0D0A '.

Maybe you are looking for

  • lost on update ios10 contacts

    I lost my contacts after software update and I do not use the icloud

  • Cannot open new tabs to the menu, with double click or Ctrl + T

    Has been using firefox without problems until this morning. Now impossible to get a new tab to open by double clicking on the tab or by selecting 'new tab' file, or by using CTRL + t. run OS x 10.6.8.

  • My Photos runs very slowly with my MacBook Pro

    My Photos runs so slowly that it tests my patience.  I have to restart my computer every time I open it.  I read a previous post about the execution of Etrecheck, and it seems that I need to install more RAM.  Is this the only question? I enclose my

  • File error!

    Hello I am trying to program my NXT module using the LabVIEW for the NXT Toolkit. I copied exactly the table of waveform of volume to get started with the LabVIEW Toolkit for LEGO® MINDSTORMS® NXT: ftp://ftp.ni.com/evaluation/mindstorms/LabVIEW_Toolk

  • How many applications can I have?

    Hello I have labview 2011 license. I'm developing an application using Labview. I want to know a few licensing issues: (1) the number of applications I develop? (2) for each application, how can I install on? (3) if I use the device provided by Natio