Loading a CLOB from a CSV file into Oracle

I'm consuming data files from a third party and I need to load them into an Oracle database. One of the files has a field that's described in the data dictionary as varchar2(8000) which will obviously need to be stored as a CLOB.
I have two questions:
1. How do I create a Model for the data file when CLOB isn't available as the Type of a column.
2. Will I need to do anything fancy to get it into a CLOB column in an Oracle table? I'm using "LKM File to Oracle (SQLLDR)" and "IKM Oracle Incremental Update (PL SQL)"

I ended up running the file through a Java app to trim the field down to 4000 characters.
I can't believe an Oracle product can't handle an Oracle data type - very poor.

Similar Messages

  • Loading data from .csv file into Oracle Table

    Hi,
    I have a requirement where I need to populate data from .csv file into oracle table.
    Is there any mechanism so that i can follow the same?
    Any help will be fruitful.
    Thanks and regards

    You can use Sql Loader or External tables for your requirement
    Missed Karthick's post ...alredy there :)
    Edited by: Rajneesh Kumar on Dec 4, 2008 10:54 AM

  • How can I import data from a csv file into databse using utl_file?

    Hi,
    I have two machines (os is windows and database is oracle 10g) that are not connected to each other and both are having the same database schema but data is all different.
    Now on one machine, I want to take dump of all the tables into csv files. e.g. if my table name is test then the exported file is test.csv and if the table name is sample then csv file name is sample.csv and so on.
    Now I want to import the data from these csv files into the tables on second machine. if I've 50 such csv files, then data should be written to 50 tables.
    I am new to this. Could anyone please let me know how can I import data back into tables. i can't use sqlloader as I've to satisfy a few conditions while loading the data into tables. I am stuck and not able to proceed.
    Please let me know how can I do this.
    Thanks,
    Shilpi

    Why you want to export into .csv file.Why not export/import? What is your oracle version?
    Read http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php
    Regards
    Biju

  • Trying to import from different csv files into multiple JTables

    This might seem like something that isn't commonly done, but I'll see if anyone has done this before anyways.
    I currently have a JTable (tab #1) and it successfully reads in the data from a CSV file to populate the cells. Now, I am looking into making 3 more JTables. I can tab between the four different tables, but I can't seem to figure out how to get the data to go to the correct JTable. Tab #1 = table, Tab #2 = table2, Tab #3 = table3, Tab #4 = table4.
    Thanks.
            try
                FileInputStream fileInput = new FileInputStream ("upcoming.csv");
                BufferedReader InputCSV = new BufferedReader (new InputStreamReader (fileInput));
                line = InputCSV.readLine(); //start reading into the records.
                    //Create data for the table.
                    //the row variable = starting row
                int row = 0;
                while(line != null)
                    tmp = line.split(",");
                    for (int col = 0; col < columnNames.length; ++col)
                        data[row][col] = tmp[col]; //store cells' data to the 2-dimensional array.
                    row++;
                    line = InputCSV.readLine();
                }//end of WHILE-statement.
            } //END of TRY-statement.
            catch(Exception e)
                System.out.println(e);
            }

    I have been successful in my quest to get 4 different datasets into 4 different JTables. The previous posters suggestion to use the Table model led me to this page:
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/table/TableModel.html
            TableModel myData = new MyTableModel();
            JTable table = new JTable(myData);I had some very similar code in my program. I use the DefaultTableModel and the SortFilterModel before having 4 different JTables.
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            DefaultTableModel model2 = new DefaultTableModel(data2, columnNames);
            DefaultTableModel model3 = new DefaultTableModel(data3, columnNames);
            DefaultTableModel model4 = new DefaultTableModel(data4, columnNames);I use the code in the first post 4 times, and only change the filename and the data#.
    I also have some code that counts the number of lines that will be needed.
    Thanks.

  • How to load excel-csv file into oracle database

    Hi
    I wanted to load excel file with csv extension(named as trial.csv) into
    oracle database table(named as dept),I have given below my experiment here.
    I am getting the following error,how should I rectify this?
    For ID column I have defined as number(5) datatype, in my control file I have defined as interger external(5),where as in the Error log file why the datatype for ID column is comming as character?
    1)my oracle database table is
    SQL> desc dept;
    Name Null? Type
    ID NUMBER(5)
    DNAME CHAR(20)
    2)my data file is(trial.csv)
    ID     DNAME
    11     production
    22     purchase
    33     inspection
    3)my control file is(trial.ctl)
    LOAD DATA
    INFILE 'trial.csv'
    BADFILE 'trial.bad'
    DISCARDFILE 'trial.dsc'
    APPEND
    INTO TABLE dept
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (ID POSITION(1:5) INTEGER EXTERNAL(5)      
    NULLIF ID=BLANKS,
    DNAME POSITION(6:25) CHAR
         NULLIF DNAME=BLANKS
    3)my syntax on cmd prompt is
    c:\>sqlldr scott/tiger@xxx control=trial.ctl direct=true;
    Load completed - logical record count 21.
    4)my log file error message is
    Column Name Position Len Term Encl Datatype
    ID           1:5 5 , O(") CHARACTER
    NULL if ID = BLANKS
    DNAME 6:25 20 , O(") CHARACTER
    NULL if DNAME = BLANKS
    Record 1: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Record 21: Rejected - Error on table DEPT, column ID.
    ORA-01722: invalid number
    Table DEPT:
    0 Rows successfully loaded.
    21 Rows not loaded due to data errors.
    0 Rows not loaded because all WHEN clauses were failed.
    0 Rows not loaded because all fields were null.
    Bind array size not used in direct path.
    Column array rows : 5000
    Stream buffer bytes: 256000
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 21
    Total logical records rejected: 21
    Total logical records discarded: 0
    Total stream buffers loaded by SQL*Loader main thread: 0
    Total stream buffers loaded by SQL*Loader load thread: 0
    5)Result
    SQL> select * from dept;
    no rows selected
    by
    balamuralikrishnan.s

    Hi everyone!
    The following are the steps to load a excell sheet to oracle table.i tried to be as simple as possible.
    thanks
    Step # 1
    Prapare a data file (excel sheet) that would be uploaded to oracle table.
    "Save As" a excel sheet to ".csv" (comma seperated values) format.
    Then save as to " .dat " file.
    e.g datafile.bat
    1,Category Wise Consumption Summary,Expected Receipts Report
    2,Category Wise Receipts Summary,Forecast Detail Report
    3,Current Stock List Category Wise,Forecast rule listing
    4,Daily Production Report,Freight carrier listing
    5,Daily Transactions Report,Inventory Value Report
    Step # 2
    Prapare a control file that define the data file to be loaded ,columns seperation value,name and type of the table columns to which data is to be loaded.The control file extension should be " .ctl " !
    e.g i want to load the data into tasks table ,from the datafile.dat file and having controlfile.ctl control file.
    SQL> desc tasks;
    Name Null? Type
    TASK_ID NOT NULL NUMBER(14)
    TASK_NAME VARCHAR2(120)
    TASK_CODE VARCHAR2(120)
    : controlfile.ctl
    LOAD DATA
    INFILE 'e:\datafile.dat'
    INTO TABLE tasks
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    (TASK_ID INTEGER EXTERNAL,
    TASK_NAME CHAR,
    TASK_CODE CHAR)
    The above is the structure for a control file.
    Step # 3
    the final step is to give the sqlldr command to execute the process.
    sqlldr userid=scott/tiger@abc control=e:\controlfile.ctl log=e:\logfile.log
    Message was edited by:
    user578762

  • How to load multiple CSV files into oracle in one go.

    Hi,
    I have project requirement like: I'll be getting one csv file as one record for the source table.
    So i need to know is there any way by which I can load multiple csv in one go. I have searched a lot on net about external table.(but problem is I can only use one consolidate csv at a time)
    and UTL_FILE same thing consolidate file is required here to load.
    but in my scenario I'll have (1000+) csv files(as records) for the table and it'd be hectic thing to open each csv file,copy the record in it and paste in other file to make consolidate one.
    Please help me ..it's very new thing for me...I have used external table for , one csv file in past but here I have to user many file.
    Table description given below.
    desc td_region_position
    POSITION_KEY             NUMBER     Primary key
    POSITION_NAME       VARCHAR2(20)     
    CHANNEL                     VARCHAR2(20)     
    LEVEL                     VARCHAR2(20)     
    IS_PARTNER             CHAR(1)     
    MARKET_CODE             VARCHAR2(20)
    CSV file example:
    POSITION_KEY|POSITION_NAME|CHANNEL|LEVEL|IS_PARTNER|MARKET_CODE
    123002$$FLSM$$Sales$$Middle$$Y$$MDM2203
    delimeter is --  $$my database version as follows:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    "CORE     10.2.0.5.0     Production"
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Productio
    NLSRTL Version 10.2.0.5.0 - ProductionEdited by: 974253 on Dec 10, 2012 9:58 AM

    if your csv files have some mask, say "mask*.csv" or by file "mask1.csv" and "mask2.csv" and ...
    you can create this.bat file
    FOR %%c in (C:\tmp\loader\mask*.csv) DO (
       c:\oracle\db\dbhome_1\BIN\sqlldr <user>@<sid>l/<password> control=C:\tmp\loader\loader.ctl data=%%c
       )and C:\tmp\loader\loader.ctl is
    OPTIONS (ERRORS=0,SKIP=1)
    LOAD DATA
      APPEND 
      INTO TABLE scott.td_region_position
      FIELDS TERMINATED BY '$$' TRAILING NULLCOLS
      ( POSITION_KEY,
         POSITION_NAME ,
         CHANNEL,
         LVL,
         IS_PARTNER,
         MARKET_CODE
      )test
    C:\Documents and Settings\and>sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 10 11:03:47 2012
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter user-name: scott
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select * from td_region_position;
    no rows selected
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
    oduction
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    C:\Documents and Settings\and>cd C:\tmp\loader
    C:\tmp\loader>dir
    Volume in drive C has no label.
    Volume Serial Number is F87F-9154
    Directory of C:\tmp\loader
    12/10/2012  10:51 AM    <DIR>          .
    12/10/2012  10:51 AM    <DIR>          ..
    12/10/2012  10:55 AM               226 loader.ctl
    12/10/2012  10:38 AM               104 mask1.csv
    12/10/2012  10:39 AM               108 mask2.csv
    12/10/2012  10:57 AM               151 this.bat
                   4 File(s)            589 bytes
                   2 Dir(s)   4,523,450,368 bytes free
    C:\tmp\loader>this.bat
    C:\tmp\loader>FOR %c in (C:\tmp\loader\mask*.csv) DO (c:\oracle\db\dbhome_1\BIN\
    sqlldr user@orcl/password control=C:\tmp\loader\loader.ctl data=%c )
    C:\tmp\loader>(c:\oracle\db\dbhome_1\BIN\sqlldr user@orcl/password control=C
    :\tmp\loader\loader.ctl data=C:\tmp\loader\mask1.csv )
    SQL*Loader: Release 11.2.0.1.0 - Production on Mon Dec 10 11:04:27 2012
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 1
    C:\tmp\loader>(c:\oracle\db\dbhome_1\BIN\sqlldr user@orcl/password control=C
    :\tmp\loader\loader.ctl data=C:\tmp\loader\mask2.csv )
    SQL*Loader: Release 11.2.0.1.0 - Production on Mon Dec 10 11:04:28 2012
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Commit point reached - logical record count 1
    C:\tmp\loader>sqlplus
    SQL*Plus: Release 11.2.0.1.0 Production on Mon Dec 10 11:04:46 2012
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter user-name: scott
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select * from td_region_position;
    POSITION_KEY POSITION_NAME        CHANNEL              LVL                  I
    MARKET_CODE
          123002 FLSM                 Sales                Middle               Y
    MDM2203
          123003 FLSM1                Sa2les               M2iddle              Y
    MDM22203
    SQL>

  • Can't paste copied entries from online CSV file into Excel spreadsheet (chatted with zzxc on 5/3/10 at around 2.30 CST but got disconnected. did not get an answer ...)

    Here is the transcript of a chat with Firefox community member zzxcon May 3/10
    You are now chatting with Firefox community member zzxc
    zzxc: Hello
    zzxc: What happens when you attempt to download a .csv file?
    seegal: hello
    seegal: it doesn't copy
    zzxc: how are you trying to copy?
    seegal: pls bear with me I'm a slow typist. Just copy selected text
    Biolizard has joined the conversation.
    zzxc: ok - which text are you selecting?
    seegal: I reconcile my checkbook (spreadsheet this way). I copy the items in my online bank acc and paste it to the spreadsheet
    seegal: I'm using Firefox /2.0.0.19. Have no problem to do this.
    zzxc: Which version of OS X?
    seegal: In all newer version nothing happens when trying to paste- just doesn't paste
    zzxc: Firefox 2.0.0.x is no longer supported, and hasn't been supported in over a year
    zzxc: Paste into Excel, from Firefox?
    seegal: Sorry, I'm ahead... /2.0.0.19
    seegal: Yes. I open my bank acc in Firefox
    zzxc: Which version of Excel?
    zzxc: It would really help if you could tell me step by step what you're doing.
    seegal: First re: your previous question: it's OS 10.4.11
    seegal: About Excell: it'as 2004 version - the lasat one produced for Macs. The specific version is 11.3.7
    seegal: So I open my bank acc online in Firfox (my primary browser). I copy the latest entry in the account and paste it into my Excel spreadsheet.
    zzxc: so, you copy direct from the web page without downloading a CSV file?
    seegal: What do you mean by downloading to CSV file? I could export from the https://chat-support.mozilla.com:9091/webchat/getimage?image=sendmessage&workgroup=support%40workgroup.chat-support.mozilla.comFirefox to the CSV file, but the other way around?
    zzxc: Are you copying your bank statement directly from the web site to Excel using the clipboard?
    seegal: sI don't use the clipboard. This is a mac. There is no need to do that. In PC it would be yes.
    zzxc: I need to know the exact steps you're taking to get them into excel
    zzxc: And I need to know what exactly goes wrong in the latest version of Firefox.
    seegal: Do you have a mac there with Firefox and Excel? It would be very easy to reproduce. Imagine you open an online bank acc, select some entries , click "copy", than proceed to your already open Excel spreadsheet and click' paste". That's it!
    zzxc: When this happens, do you get cryptic code pasted into Excel?
    seegal: As I said before: in all newer versions starting with 3.0 when I go to Excel to "paste" from my bank acc nothing happens. It does not paste. No, I don't get a cryptic code pasted, just NOTHING.
    zzxc: what if you paste into MS Word instead?
    seegal: haven't tried that, the formatting most likely would be lost. Tried that with an other Exc el spreadsheet- it lost all the formating and pasted as continous text.
    == This happened ==
    Every time Firefox opened
    == Pls. see copy of the chat above. THIS A MAC OS X. In older versions, prior to 3.0 I could copy from CSV file on the website Ibank acc) and paste directly to my Excel spreadheet to reconcile my account.

    See also:
    Table2Clipboard: https://addons.mozilla.org/firefox/addon/1852
    TableTools: https://addons.mozilla.org/firefox/addon/2637

  • Need to load data from source .CSV files to oracle target database.

    Hi,
    This is the my scenario
    I have .CSV files in ftp folder and need to load the data into target tables.
    For that i need to create package and load the data into daily basis.
    But some time .csv file name will vary daily basis.
    can you any one suggest me???
    Thanks in Advacne.
    Zakeer

    Dear Roy,
    Thanks for your response
    Now I am able to extract the .zip file OdiUnZip (file). and loading data into target this is chapping in static way
    and my scenario is that some time i will get .zip files with different names with different .csv files
    i need to dynamically find the new .zip file and extract it and load the data into target.
    Please advice me..
    Thanks in advance
    Zakeer

  • How to upload above20000 records csv files into oracle table,Oracle APEX3.2

    Can any one help me how to CSV upload more than 20,000 records using APEX 3.2 upload process.i am using regular upload process using BOLB file
    SELECT blob_content,id,filename into v_blob_data,v_file_id,v_file_name
    FROM apex_application_files
    WHERE last_updated = (select max(last_updated)
    from apex_application_files WHERE UPDATED_BY = :APP_USER)
    AND id = (select max(id) from apex_application_files where updated_by = :APP_USER);
    I tried to upload but my page getting time out. my application best working up to 1000 records. after that its getting timed out.Each record is storing 2 secornds in the oracle table.So 1000 records it taking 7 minuts after that APEX upload webpage getting timed out
    please help me with source how to speed upload csv file process or help another best with with source example.
    Thanks,
    Sant.
    Edited by: 994152 on Mar 15, 2013 5:38 AM

    See this posting:
    Internet Explorer Cannot Display
    There, I provided a couple of links on this particular issue. You need to change the timeout on your application server.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    http://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

  • Uploading Data from a Flat file into Oracle Database

    Hi,
    I am a novice to Java . SO, please bear with me. I have a reqiurement where I have a flat file or excel file from which I need to read the data and insert into Oracle Database. The falt file will exist on the client machine. I have been reading and I see this can be done through I/O Streams. Correct me if I am wrong. I am looking for a sample code to get started. Any Java expert has an answer for it, I will appreciate it.
    Thanks

    Try UploadBean. It allows to upload files (from a browser) in Oracle.
    http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html
    You will find JSP and servlet samples.

  • How do I import the data from Excel (.xls) file into Oracle Database table

    I have an excel file with 5 columns of 5000 rows.
    I have to import 5000 rows of data into my oracle table with
    same column names & Data types.
    What is the best advise for this ?
    Thanks.
    Srini

    You can connect to Oracle from Excel directly. I know you can read data but am not sure if you can export data.
    Other option is to import the data into Access.
    Create an ODBC connection for Oracle
    Use the to connect to Oracle from Access
    Export data to Oracle from Access
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Load / Update Table from a .csv file

    Hi All,
    I thought I would just throw this out there..be kind.
    I have a requirement to build a page that allows the user to upload a excel (well I'll have them save it as a .csv) and upate an existing table in their schema.
    I have successfully created a similar page for inserting into an existing table however my update is not working. Then I realized what the Oracle Application Express Tool does that for me on, LOAD DATA page. The feature I like best is that after browsing for the file and clicking next it shows the column header and the row data underneath. I would really like to duplicate the functionality of this page.
    I looked into the flows schema found related procedures , for example wwv_flow_load_excel_data,but I'm lost on how to use them.
    Is there a way to duplicate the LOAD DATA Page and fit it to meet the users requirement?
    Also I have included my coding attempt :
    CREATE OR REPLACE PROCEDURE exceltotable2
    AS
    NAME: exceltotable
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 11/17/2008 1. Created this procedure.
    NOTES:
    Automatically available Auto Replace Keywords:
    Object Name: exceltotable
    Sysdate: 11/17/2008
    Date and Time: 11/17/2008, 2:02:03 PM, and 11/17/2008 2:02:03 PM
    Username: (set in TOAD Options, Procedure Editor)
    Table Name: (set in the "New PL/SQL Object" dialog)
    v_blob_data BLOB;
    v_blob_len NUMBER;
    v_position NUMBER;
    v_raw_chunk RAW (10000);
    v_char CHAR (1);
    c_chunk_len NUMBER := 1;
    v_line VARCHAR2 (32767) := NULL;
    v_data_array APEX_APPLICATION_GLOBAL.VC_ARR2;
    v_rows NUMBER;
    v_asset_id NUMBER;
    v_new_location GINOS_LOCATION.ID_LOCATION%TYPE ;
    sql_stmt VARCHAR2 (2000);
    --delete from data_upld;
    BEGIN
    -- Read data from wwv_flow_files</span>
    SELECT blob_content
    INTO v_blob_data
    FROM wwv_flow_file_objects$
         WHERE NAME = 'F32700/scannedforrdc.csv';
         --(used this for testing)
    -- WHERE last_updated = (select max(last_updated) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY
    -- = 'ADMIN')
    --and id = (select max(id) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY = 'ADMIN');
    v_blob_len := DBMS_LOB.getlength (v_blob_data);
    v_position := 1;
    -- Read and convert binary to char</span>
    WHILE (v_position <= v_blob_len)
    LOOP
    v_raw_chunk := DBMS_LOB.SUBSTR (v_blob_data, c_chunk_len, v_position);
    v_char := CHR (hex_to_decimal(RAWTOHEX(v_raw_chunk)));
    v_line := v_line || v_char;
    v_position := v_position + c_chunk_len;
    -- When a whole line is retrieved </span>
    IF v_char = CHR (10)
    THEN
    -- Convert comma to : to use wwv_flow_utilities </span>
    v_line := REPLACE (v_line, ',', ':');
    -- Convert each column separated by : into array of data </span>
    v_data_array := APEX_UTIL.string_to_table (v_line);
    -- Update assets with RDC location
    -- First get the current location id of the RDC
    -- Next take each serial number from the spreadsheet and update the location and rack details </span>
    Select id_location into v_new_location from ginos_location gl, ginos_site gs, ginos_agency ga
    where nm_office = 'OCFS Resource Distribution Center' and gl.id_site = gs.id_site
    And gl.id_agency = ga.id_agency And ga.nm_agency ='Office of Children and Family Services';
    -- test with only the serial number/location
    UPDATE GINOS_ASSET SET ID_LOCATION = v_new_location WHERE NM_SERIAL = v_data_array(1);
    -- Clear out
    v_line := NULL;
    v_rows := v_rows + 1;
    END IF;
    END LOOP;
    END;
    Any advice/assistance is always appreciated
    Thanks
    Moe

    Dan
    Thank You for your reply, I actually bookmark your site yesterday when googling this problem.
    I am going to give it a try. I have ran through steps 1 through 4. Step 4 , I modified to my page.
    Just a little more help..
    do I put my update table code in the procedure (step 4) - how do I view and extract the information from the collection?
    DECLARE
    l_blob BLOB;
    PROCEDURE cleanup
    IS
    BEGIN
    DELETE FROM WWV_FLOW_FILES
    WHERE name = :P103_UPLOAD;
    END cleanup;
    BEGIN
    SELECT blob_content
    INTO l_blob
    FROM WWV_FLOW_FILES
    WHERE name = :P103_UPLOAD;
    csv.create_collection_from_blob(l_blob, 'CSV_UPLOAD', 'Y');
    -- I looked in the ginodba schema (the ref schema for the app) for this collection but it's not there
    cleanup;
    EXCEPTION
    WHEN OTHERS
    THEN
    cleanup;
    RAISE;
    END;
    Thanks Again
    MOe

  • SQL*Loader - How to load only a few columns from a .csv file to ora table

    Hi there,
    Could anyone please let me know how to load few columns from a .csv
    file into a oracle table using SQL*Loader.
    I know how to create a .dat and .ctl file and run the sql loader.
    Suppose I have a .csv file with
    col1, col2, col3, col4
    and I only need to load col1 and col3 into col_a and col_b respectively
    in table_a?
    structure of table_ a
    col_a,
    col_b
    Please advice

    Try like..it i will work..
    LOAD DATA
    INFILE 'test.txt'
    LOAD DATA
    TRUNCATE INTO TABLE T1
    FIELDS TERMINATED BY ','
    (col1,
    col2 FILLER,
    col3,
    col4 FILLER
    )

  • How to read/write .CSV file into CLOB column in a table of Oracle 10g

    I have a requirement which is nothing but a table has two column
    create table emp_data (empid number, report clob)
    Here REPORT column is CLOB data type which used to load the data from the .csv file.
    The requirement here is
    1) How to load data from .CSV file into CLOB column along with empid using DBMS_lob utility
    2) How to read report columns which should return all the columns present in the .CSV file (dynamically because every csv file may have different number of columns) along with the primariy key empid).
    eg: empid report_field1 report_field2
    1 x y
    Any help would be appreciated.

    If I understand you right, you want each row in your table to contain an emp_id and the complete text of a multi-record .csv file.
    It's not clear how you relate emp_id to the appropriate file to be read. Is the emp_id stored in the csv file?
    To read the file, you can use functions from [UTL_FILE|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#BABGGEDF] (as long as the file is in a directory accessible to the Oracle server):
    declare
        lt_report_clob CLOB;
        l_max_line_length integer := 1024;   -- set as high as the longest line in your file
        l_infile UTL_FILE.file_type;
        l_buffer varchar2(1024);
        l_emp_id report_table.emp_id%type := 123; -- not clear where emp_id comes from
        l_filename varchar2(200) := 'my_file_name.csv';   -- get this from somewhere
    begin
       -- open the file; we assume an Oracle directory has already been created
        l_infile := utl_file.fopen('CSV_DIRECTORY', l_filename, 'r', l_max_line_length);
        -- initialise the empty clob
        dbms_lob.createtemporary(lt_report_clob, TRUE, DBMS_LOB.session);
        loop
          begin
             utl_file.get_line(l_infile, l_buffer);
             dbms_lob.append(lt_report_clob, l_buffer);
          exception
             when no_data_found then
                 exit;
          end;
        end loop;
        insert into report_table (emp_id, report)
        values (l_emp_id, lt_report_clob);
        -- free the temporary lob
        dbms_lob.freetemporary(lt_report_clob);
       -- close the file
       UTL_FILE.fclose(l_infile);
    end;This simple line-by-line approach is easy to understand, and gives you an opportunity (if you want) to take each line in the file and transform it (for example, you could transform it into a nested table, or into XML). However it can be rather slow if there are many records in the csv file - the lob_append operation is not particularly efficient. I was able to improve the efficiency by caching the lines in a VARCHAR2 up to a maximum cache size, and only then appending to the LOB - see [three posts on my blog|http://preferisco.blogspot.com/search/label/lob].
    There is at least one other possibility:
    - you could use [DBMS_LOB.loadclobfromfile|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978]. I've not tried this before myself, but I think the procedure is described [here in the 9i docs|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl12bfl.htm#879711]. This is likely to be faster than UTL_FILE (because it is all happening in the underlying DBMS_LOB package, possibly in a native way).
    That's all for now. I haven't yet answered your question on how to report data back out of the CLOB. I would like to know how you associate employees with files; what happens if there is > 1 file per employee, etc.
    HTH
    Regards Nigel
    Edited by: nthomas on Mar 2, 2009 11:22 AM - don't forget to fclose the file...

  • Script to import contacts from CSV file into Address Book

    Hi,
    I am wondering if it would be possible to import contacts from a CSV file into a group in Address Book using applescript, and if so, if anyone is aware of a script that does this or something similar.
    I have a CSV file with three columns 'First Name', 'Last Name' and 'Email Address'.  I would like these to correspond with  'First', 'Last' and (Work) 'Email' in Address Book.
    Ideally the script would also check to see if entries already exist for the people being imported, but this is less crucial.
    Thanks in advance for any assistance,
    Nick

    Hi,
    Test this on a very small csv file (four or five contacts) to see if it works for you. It will not de-duplicate. You don't give the name of the group, so you'll need to replace Name of group in the second line with your group name, enclosed in double quotes.
    --begin script
    set the_people to read (choose file with prompt "Choose your CSV file")
    set the_group to "Name of group"
    set old_tids to AppleScript's text item delimiters
    set AppleScript's text item delimiters to ","
    set par_count to (count paragraphs in the_people)
    repeat with x from 1 to par_count
              set next_par to paragraph x of the_people
              set first_name to text item 1 of next_par
              set last_name to text item 2 of next_par
              set e_mail to text item 3 of next_par
              tell application "Address Book"
                        set nu_person to make new person with properties {first name:first_name, last name:last_name}
      make new email at end of emails of nu_person with properties {label:"Work", value:e_mail}
                        add nu_person to group the_group
      save
              end tell
    end repeat
    set AppleScript's text item delimiters to old_tids
    --end script
    Watch out for bad line breaks in the lines beginning "set nu_person..." and "make new email..."

Maybe you are looking for

  • Monitoring of remote system's Transactional RFC and Queued RFC

    Hello, In our production system, in rz20- CCMS monitor templates- Communication-Transactional RFC and Queued RFc- outbound queues- Queues otherwise not monitored we can see blocked queues for each client. System is connected to solution manager and w

  • My Iphone 4 keeps restarting its self!

    Hello, i recently upgraded my Iphone 4 to IOS 6 and ever since then, when i get a text msg and i slide the messege icon in the lockscreen my phone restarts. ive erased it and reinstalled a fresh IOS 6 and it stil does this how can i fix it?

  • WINRAR NEEDS ADMINISTRATIVE RIGHTS TO UNZIP FILES

    I have domain network consisting windows 7 professional 64 bit as clients and windows server 2008 standard and 2012 as servers. My problem is when standard users try to open files zipped in winrar software. They need administrative privileges. Can an

  • Component Based on HTTPService

    Is it possible to create a new MXML component based on HTTPService? Thank you.

  • Disk Utility crashes every time I try to start it

    So I have tried clicking on "Disk Utility" and it starts bouncing in the dock, then goes away, the computer hangs or a few seconds, and I get a window saying that it has unexpectedly quit. It does this every time, without fail, even after a reboot. T