External Table which can handle appending multiple csv files dynamic

I need an external table which can handle appending multiple csv files' values.
But the problem I am having is : the number of csv files are not fixed.
I can have between 2 to 6-7 files with the suffix as current_date. Lets say it will be like my_file1_aug_08_1.csv, my_file1_aug_08_2.csv, my_file1_aug_08_3.csv etc. and so on.
I can do it by following as hardcoding if I know the number of files, but unfortunately the number is not fixed and need to something dynamically to inject with a wildcard search of file pattern.
CREATE TABLE my_et_tbl
  my_field1 varchar2(4000),
  my_field2 varchar2(4000)
ORGANIZATION EXTERNAL
  (  TYPE ORACLE_LOADER
     DEFAULT DIRECTORY my_et_dir
     ACCESS PARAMETERS
       ( RECORDS DELIMITED BY NEWLINE
        FIELDS TERMINATED BY ','
        MISSING FIELD VALUES ARE NULL  )
     LOCATION (UTL_DIR:'my_file2_5_aug_08.csv','my_file2_5_aug_08.csv')
REJECT LIMIT UNLIMITED
NOPARALLEL
NOMONITORING;Please advice me with your ideas. thanks.
Joshua..

Well, you could do it dynamically by constructing location value:
SQL> CREATE TABLE emp_load
  2      (
  3       employee_number      CHAR(5),
  4       employee_dob         CHAR(20),
  5       employee_last_name   CHAR(20),
  6       employee_first_name  CHAR(15),
  7       employee_middle_name CHAR(15),
  8       employee_hire_date   DATE
  9      )
10    ORGANIZATION EXTERNAL
11      (
12       TYPE ORACLE_LOADER
13       DEFAULT DIRECTORY tmp
14       ACCESS PARAMETERS
15         (
16          RECORDS DELIMITED BY NEWLINE
17          FIELDS (
18                  employee_number      CHAR(2),
19                  employee_dob         CHAR(20),
20                  employee_last_name   CHAR(18),
21                  employee_first_name  CHAR(11),
22                  employee_middle_name CHAR(11),
23                  employee_hire_date   CHAR(10) date_format DATE mask "mm/dd/yyyy"
24                 )
25         )
26       LOCATION ('info*.dat')
27      )
28  /
Table created.
SQL> select * from emp_load;
select * from emp_load
ERROR at line 1:
ORA-29913: error in executing ODCIEXTTABLEOPEN callout
SQL> set serveroutput on
SQL> declare
  2      v_exists      boolean;
  3      v_file_length number;
  4      v_blocksize   number;
  5      v_stmt        varchar2(1000) := 'alter table emp_load location(';
  6      i             number := 1;
  7  begin
  8      loop
  9        utl_file.fgetattr(
10                          'TMP',
11                          'info' || i || '.dat',
12                          v_exists,
13                          v_file_length,
14                          v_blocksize
15                         );
16        exit when not v_exists;
17        v_stmt := v_stmt || '''info' || i || '.dat'',';
18        i := i + 1;
19      end loop;
20      v_stmt := rtrim(v_stmt,',') || ')';
21      dbms_output.put_line(v_stmt);
22      execute immediate v_stmt;
23  end;
24  /
alter table emp_load location('info1.dat','info2.dat')
PL/SQL procedure successfully completed.
SQL> select * from emp_load;
EMPLO EMPLOYEE_DOB         EMPLOYEE_LAST_NAME   EMPLOYEE_FIRST_ EMPLOYEE_MIDDLE
EMPLOYEE_
56    november, 15, 1980   baker                mary            alice     0
01-SEP-04
87    december, 20, 1970   roper                lisa            marie     0
01-JAN-99
SQL> SY.
P.S. Keep in mind that changing location will affect all sessions referencing external table.

Similar Messages

  • Appending multiple *.csv files while retaining the original file name in the first column

    Hi guys it's been awhile.
    I'm trying to append multiple *.csv files while retaining the original file name in the first column, the actual data set is about 40 files.
    file a.csv contains:
    1, line one in a.csv
    2, line two in a.csv
    file b.csv contains:
    1, line one in b.csv
    2, line two in b.csv
    output.csv result is this:
    I would like this:
    a.csv, 1, line one in a.csv
    a.csv, 2, line two in a.csv
    b.csv, 1, line one in b.csv
    b.csv, 2, line two in b.csv
    Any suggestions to speed up my hobbling attempts would be aprieciated
    Thanks,
    -SS
    Solved!
    Go to Solution.

    What you could do is given in the attachment.
    Started with 2 files :
    a.csv
    copy of a.csv
    Both with data :
    1;1.123
    2;2.234
    3;3.345
    Output :
    a.csv;1;1.123
    a.csv;2;2.234
    a.csv;3;3.345
    Copy of a.csv;1;1.123
    Copy of a.csv;2;2.234
    Copy of a.csv;3;3.345
    If you have more questions, just shoot
    Kind regards,
    - Bjorn -
    Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's
    LabVIEW 5.1 - LabVIEW 2012
    Attachments:
    AppendingCSV.JPG ‏73 KB

  • In creating a fillable PDF in XI Pro, can I insert a table which can be tabbed through?

    In creating a fillable PDF in XI Pro, can I insert a table which can be tabbed through?

    You're in luck. Create the first field and then right-click it (in Form Edit mode) and select Create Multiple Copies. You'll be able to specify how many copies of the fields to generate, and at what intervals. The nice thing is that although the properties of the new fields will be identical to the source one, they'll each have a unique name, so you'll get an instant "table" of fields.

  • Using table comparison can we use multiple tables as source?

    Using table comparison can we use multiple tables as source?
    Thank you very much for the helpful info.

    Table Comparison
    1) Input Data coming in
    2) Comparison table (table to which the data is compared)
    3) Output (input rows with respective opcodes based on the comparison result of input dataset with the comparison table)
    If your question is whether table comparison can accept union/join of multiple table sources, you can achieve by using merge/query transforms and then feeding to table comparison. Here, you have to be careful about choosing the primary keys inside table comparison

  • A transacction or table which can display all the souce system

    Hi,
    Is there any transaction or table which can display all the source systems?
    Thanks in advance.

    RSA1->Modeling-> Click on Source Systems, here you can see all the source systems connected with BW.
    tcode: SM59 & expand all the connections. Here you can see all the connections.
    Hope it helps..

  • How to create a Z* table which can maintain through SM30?

    How to create a Z* table which can maintain through SM30? Thanks!

    This question had been asked millions of times...you just need to search the forums...
    Quick hint...goto SE11...the utilities menu and then Table Maintenance Generator.
    Greetings,
    Blag.

  • How can I have a csv file read from excel to labview.

    Hi,
    I would like to read multiple csv files from excel to labview, creating a duplicate of the tables in excel, which would allow me to then draw some graphs for data analysis and comparison between the two.
    Are there any examples that could be useful to what I am trying to do?
    Thanks

    Patel33 wrote:
    From one of the csv files, I only require 3 of the columns. Is there a way to only read that part of the csv file?
    No. The characters in a file are just one long string and delimiters and linefeeds are special characters that defined where fields and lines start and end. As such, columns are interlaced into the file and consists of many small sections, where the position depends on the number of characters in each field, which is typically variable. You really need to read the entire file, then only look at the interesting columns later.
    LabVIEW Champion . Do more with less code and in less time .

  • Can we give multiple destination files for a crystal report.

    Hi all,
    Can i give multiple destination files for crystal check process when the out put type is file.
    What i want is the text file, which will be created at the destination given by the user, must be created at other location also.
    Please help me.
    Thank you,
    Bye.

    Multiple default values for a presentation variable is only possible in 11g as Srini Said.
    Check mark : Enable user to select multiple values. (under variable datatypes)
    http://obieetraining11.blogspot.com/2012/08/obiee-11g-using-presentation-variable.html
    If it is 10g, then it is not possible.

  • How can I print multiple PDF files at once using Windows 7?

    How can I print multiple PDF files at once, on an HP LJ Pro 400 xcolocr printer without opening each
    one separately using Windows 7?

    I am sorry, but to get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial printer. You can do this at http://h30499.www3.hp.com/hpeb/
    I hope this helps.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • HT1751 if I move my iTunes library to an external hard drive can my computer access these files in iTunes or do I need to move them back to play music, watch movies, etc.???

    If I move my iTunes library to an external hard drive, can my MacBookPro access these files in iTunes or do I need to move them backto my MacBookPro to play music, watch movies, etc.???
    Trying to alleviate some disc space on my Mac!!!

    Yes, it can. Launch iTunes with the Option key held down and navigate to that instance of the library.
    (86939)

  • Script to merge multiple CSV files together with no duplicate records.

    I like a Script to merge multiple CSV files together with no duplicate records.
    None of the files have any headers and column A got a unique ID. What would be the best way to accomplish that?

    OK here is my answer :
    2 files in a directory with no headers.
    first column is the unique ID, second colomun you put whatever u want
    The headers are added when using the import-csv cmdlet
    first file contains :
    1;a
    2;SAMEID-FIRSTFILE
    3;c
    4;d
    5;e
    second file contains :
    6;a
    2;SAMEID-SECONDFILE
    7;c
    8;d
    9;e
    the second file contains the line : 2;b wich is the same in the first file
    the code :
    $i = 0
    Foreach($file in (get-childitem d:\yourpath)){
    if($i -eq 0){
    $ref = import-csv $file.fullname -Header id,value -Delimiter ";"
    }else{
    $temp = import-csv $file.fullname -Header id,value -Delimiter ";"
    foreach($line in $temp){
    if(!($ref.id.contains($line.id))){
    $objet = new-object Psobject
    Add-Member -InputObject $objet -MemberType NoteProperty -Name id -value $line.id
    Add-Member -InputObject $objet -MemberType NoteProperty -Name value -value $line.value
    $ref += $objet
    $i++
    $ref
    $ref should return:
    id                                                         
    value
    1                                                          
    a
    2                                                          
    SAMEID-FIRSTFILE
    3                                                          
    c
    4                                                          
    d
    5                                                          
    e
    6                                                          
    a
    7                                                          
    c
    8                                                          
    d
    9                                                          
    e
    (get-childitem d:\yourpath) -> yourpath containing the 2 csv file

  • Why can't I open .csv files in Excel 2013?

    We purchased (20) new machines all with Office 2013 (OEM) version.  We can no longer open .csv files with Excel 2013.  When we go to a machine with Office 2010 it opens perfectly.  The issue is with some change to Excel.  I see a lot
    of complaints on the internet about this issue.  Since we have OEM versions of Office, I am not entitled to a downgrade to 2010.  I need to know what Microsoft is doing to fix this issue, or need them to grant us rights to downgrade. 

    Hi,
    In regarding the issue, I had tested in Excel 2013 of my PC. It seems worked fine. Thus, I suggest you try to do the following methods to test.
    1. Import the CSV file into Excel 2013. Click Data tab>From Text
    http://superuser.com/questions/407082/easiest-way-to-open-csv-with-commas-in-excel
    2. Did you get en error message "SYLK: File format is not valid" when you open CSV file?
    If it was, please try to follow the link to fix the issue:
    http://support.microsoft.com/kb/323626
    3. Please try copy one of the CSV file to notepad and save it as a new name to test.
    4. You'd better upgrade the lastest patches.
    Regards,
    George Zhao
    TechNet Community Support

  • Process CSV-Files dynamically

    Hi all,
    I need to process CSV-Files dynamically, i.e. not using a static order for splitting the values of the lines into the according variables, but determining the mapping dynamically using a header line in the CSV-File.
    For instance:
    #dcu;item;subitem
    827160;5111001000;3150
    So if the order in the the CSV-File changes to e.g.
    #item;dcu;subitem
    5111001000;827160;3150
    the program should fill the corresponding variables (ls_upload-dcu, ls_upload-item, ls_load-subitem) dynamically without the need to change the code.
    If anyone has a solution, please let me know.
    Thanks,
    Thomas

    Try to use variants concepts

  • How to import external table, which exist in export dump file.

    My export dump file has one external table. While i stated importing into my developement instance , I am getting the error "ORA-00911: invalid character".
    The original definition of the extenal table is as given below
    CREATE TABLE EXT_TABLE_EV02_PRICEMARTDATA
    EGORDERNUMBER VARCHAR2(255 BYTE),
    EGINVOICENUMBER VARCHAR2(255 BYTE),
    EGLINEITEMNUMBER VARCHAR2(255 BYTE),
    EGUID VARCHAR2(255 BYTE),
    EGBRAND VARCHAR2(255 BYTE),
    EGPRODUCTLINE VARCHAR2(255 BYTE),
    EGPRODUCTGROUP VARCHAR2(255 BYTE),
    EGPRODUCTSUBGROUP VARCHAR2(255 BYTE),
    EGMARKETCLASS VARCHAR2(255 BYTE),
    EGSKU VARCHAR2(255 BYTE),
    EGDISCOUNTGROUP VARCHAR2(255 BYTE),
    EGREGION VARCHAR2(255 BYTE),
    EGAREA VARCHAR2(255 BYTE),
    EGSALESREP VARCHAR2(255 BYTE),
    EGDISTRIBUTORCODE VARCHAR2(255 BYTE),
    EGDISTRIBUTOR VARCHAR2(255 BYTE),
    EGECMTIER VARCHAR2(255 BYTE),
    EGECM VARCHAR2(255 BYTE),
    EGSOLATIER VARCHAR2(255 BYTE),
    EGSOLA VARCHAR2(255 BYTE),
    EGTRANSACTIONTYPE VARCHAR2(255 BYTE),
    EGQUOTENUMBER VARCHAR2(255 BYTE),
    EGACCOUNTTYPE VARCHAR2(255 BYTE),
    EGFINANCIALENTITY VARCHAR2(255 BYTE),
    C25 VARCHAR2(255 BYTE),
    EGFINANCIALENTITYCODE VARCHAR2(255 BYTE),
    C27 VARCHAR2(255 BYTE),
    EGBUYINGGROUP VARCHAR2(255 BYTE),
    QTY NUMBER,
    EGTRXDATE DATE,
    EGLISTPRICE NUMBER,
    EGUOM NUMBER,
    EGUNITLISTPRICE NUMBER,
    EGMULTIPLIER NUMBER,
    EGUNITDISCOUNT NUMBER,
    EGCUSTOMERNETPRICE NUMBER,
    EGFREIGHTOUTBOUNDCHARGES NUMBER,
    EGMINIMUMORDERCHARGES NUMBER,
    EGRESTOCKINGCHARGES NUMBER,
    EGINVOICEPRICE NUMBER,
    EGCOMMISSIONS NUMBER,
    EGCASHDISCOUNTS NUMBER,
    EGBUYINGGROUPREBATES NUMBER,
    EGINCENTIVEREBATES NUMBER,
    EGRETURNS NUMBER,
    EGOTHERCREDITS NUMBER,
    EGCOOP NUMBER,
    EGPOCKETPRICE NUMBER,
    EGFREIGHTCOSTS NUMBER,
    EGJOURNALBILLINGCOSTS NUMBER,
    EGMINIMUMORDERCOSTS NUMBER,
    EGORDERENTRYCOSTS NUMBER,
    EGRESTOCKINGCOSTSWAREHOUSE NUMBER,
    EGRETURNSCOSTADMIN NUMBER,
    EGMATERIALCOSTS NUMBER,
    EGLABORCOSTS NUMBER,
    EGOVERHEADCOSTS NUMBER,
    EGPRICEADMINISTRATIONCOSTS NUMBER,
    EGSHORTPAYMENTCOSTS NUMBER,
    EGTERMCOSTS NUMBER,
    EGPOCKETMARGIN NUMBER,
    EGPOCKETMARGINGP NUMBER,
    EGWEIGHTEDAVEMULTIPLIER NUMBER
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY EV02_PRICEMARTDATA_CSV_CON
    ACCESS PARAMETERS
    LOCATION (EV02_PRICEMARTDATA_CSV_CON:'VPA.csv')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;
    While importing , when i seen the log file , it is failing the create the external table. Getting the error "ORA-00911: invalid character".
    Can some one suggest how to import external tables
    Addressing this issue will be highly appriciated.
    Naveen

    Hi Srinath,
    When i observed the create table syntax of external table from import dump log file, it show few lines as below. I could not understand these special characters. And create table definationis failing with special character viz ORA-00911: invalid character
    ACCESS PARAMETERS
    LOCATION (EV02_PRICEMARTDATA_CSV_CON:'VPA.csv').
    I even observed the create table DDL from TOAD. It is same as i mentioned earlier
    Naveen

  • Web ADI Error when using column from table which can be NULL as parameter

    Hi
    We have a custom integrator which queries the records and downloads into excel sheet. There is parameter list attached to it. One of the parameter is on a field which can have NULL. When we try running the ADI , we are getting the error :
    Fatal error: Please have your system administrator view the bne.log file.
    java.lang.NullPointerException
    Please contact your support representative
    Please help.
    Regards,
    Pradeep.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Stefan Misch ([email protected]):
    Yep - if you try:
    create unique index XAK2_A_ARTIKEL
    on A_ARTIKEL(CUST_ID, EXTERNAL_ID);
    I get error ORA-01452, because of duplicate keys. I verified, that within a each CUST_ID, there is no duplicate non-null EXTERNAL_ID, but there are lots of rows for each CUST_ID where EXTERNAL_ID is NULL.
    Thanks for your help.
    Stefan<HR></BLOCKQUOTE>
    Create a view on your table, that you will use for inserts.
    Then, create a trigger INSTEAD OF INSERT on your view. You can perform the checks for uniqueness in it...
    Hope this will help...
    Thomas.
    null

Maybe you are looking for

  • Ipod 4G Will not Dock via USB

    Hi, My IPod 4G is not being recognised by XP, Windows always throws up the message 'USB Device Not Recognised' when I dock via the USB cable. Windows only seems to recognise the device when using a firewire cable.

  • Using BAPI_PO_CREATE1

    I would like use bapi to create po, once call the function, some warning occur, "No instance of object type PurchaseOrder has been created. External reference: Purchase order still contains faulty items Can delivery date be met?" Can i bypass the war

  • How to export images in Acrobat Pro X v10.x for Mac?

    How to export images using Acrobat Pro X v10.1.1? This is a positive criticism: it was easy with Acrobat Pro X v.9.x. The new Acrobat interface without menus and submenus is awkward and utterly anti-intuitive. If it ain't broke don't fix it!!! Thanks

  • [ADF-UIX] updating some fields after selecting an item from messageChoice

    Hi, I'll try and keep it short and simple. How do I do the following: I have 2 ViewObjects: department - employees, they have a 1 - many relationship. But there's no master-detail in my ViewObjects (no link between my view objects) On my UIX page I h

  • Abap function module for material standard price.

    Dear Team, Can anyone tell me the abap function module for getting material  standard price respective of date and material code as input. I have observe table MBEW, where we will get standard price of a material for last change date. Not getting any