Can we strore .CSV file into CLOB datatype

hi
can we strore .CSV file into CLOB datatype
its giving me error ot hexa coonversion?
can anyone provide sample code...
when i m sending mail from oracle database when i send as blob object then nope but when i send attachment stored in table with clob column it gives me hex to raw conversion error
folllowing is my code--
CREATE OR REPLACE PROCEDURE com_maildata_prc1( pi_sender IN com_batch_contact_dtl.strreceivername%TYPE,
pi_recipients IN com_batch_contact_dtl.stremailaddr%TYPE,
pi_subject IN VARCHAR2 ,
pi_text IN VARCHAR2 ,
pi_filename IN VARCHAR2 ,
pi_blob IN cLOB
IS
conn utl_smtp.connection;
i NUMBER;
len NUMBER;
BEGIN
('com_send_email_prc',Vn_Process_Id);
conn := demo_mail.begin_mail( sender => pi_sender,
recipients => pi_recipients,
subject => pi_subject,
mime_type => demo_mail.MULTIPART_MIME_TYPE
demo_mail.begin_attachment(conn => conn,
mime_type => 'application/csv',
inline => TRUE,
filename => pi_filename,
transfer_enc => 'base64'
-- split the Base64 encoded attachment into multiple lines
i := 1;
len := DBMS_LOB.getLength(pi_blob);
WHILE (i < len) LOOP
IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
UTL_SMTP.Write_raw_Data (conn
, UTL_ENCODE.Base64_Encode(
DBMS_LOB.Substr(pi_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
ELSE
UTL_SMTP.Write_raw_Data (conn
, UTL_ENCODE.Base64_Encode(
DBMS_LOB.Substr(pi_blob, (len - i)+1, i)));
END IF;
UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
END LOOP;
demo_mail.end_attachment(conn => conn);
demo_mail.attach_text(
conn => conn,
data => pi_text,
mime_type => 'text/csv');
demo_mail.end_mail( conn => conn );
END;
Thanx in advance...
Message was edited by:
user549162
Message was edited by:
user549162

Hi
Ignore "SQL*Loader-292: ROWS parameter ignored when an XML, LOB or VARRAY column is loaded" error
after importing your csv file just change length CHAR(100000).
ex: your column col1 CHAR(1000) to change CHAR(100000).
and deploy your mapping and execute
Regards,
Venkat

Similar Messages

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

  • How to convert csv files into java bean objects?

    Hi,
    I have a CSV file, I want to store the data availabale in that csv file into java bean, I am new to this csv files how can I convert CSV files into java beans.
    Please help me.
    Adavanced Thanks,
    Mahendra

    You can use the java.io API to read (and write) files. Use BufferedReader to read the CSV file line by line. Use String#split() to split each line into an array of parts which were separated by comma (or semicolon). If necessary run some escaping of quotes. Finally collect all parts in a two-dimensional List of Strings or a List of Javabeans.
    java.io API: [http://www.google.com/search?q=java.io+javase+api+site:sun.com]
    java.io tutorial: [http://www.google.com/search?q=java.io+tutorial+site:sun.com]
    Basic CSV parser/formatter example: [http://balusc.blogspot.com/2006/06/parse-csv-upload.html]

  • Looking for a Notes app that I can import CSV files into?

    As the title says, I'm looking for a good notes application for my iPhone that I can import CSV files into. I have tried both Appigo and Notespark, but I can't easily scroll through them, as I have 2,000+ notes. Is there any app that I can import my notes into and also scroll through quickly? I'd like something that works similarly to how you scroll through songs on the iPhone/iTouch, with the column on the right where you can skip to songs (notes, in this case) that start with a certain letter.
    Thanks!

    Hi Tx Tar Heel,
    I've been using Office2HD: https://itunes.apple.com/us/app/office2-hd/id364361728?mt=8
    Its cheaper than Numbers and it also works for Word and PowerPoint files too. I like the Dropbox integration. I can start on my Office docs (Word, Excel, PowerPoint) in the office and then edit those files with Office2HD when I'm out of the office. Files saves right back to Dropbox so that when I get back to the office the files are already updated. Not bad for a $7.99 app!
    Hope this helps!
    ~Joe

  • 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

  • Load CSV file into single CLOB

    Hello Oracler,
    is there a good way to load a csv file into PL/SQL a Clob variable ?
    Ilja

    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978

  • Read text file into clob column

    Dear Oracle users and Oracle support,
    I have a text file that includes hundreds of data entries. The format is below. What I need to do is read each entry (
    <DATALOAD ................</DATALOAD>) into the CLOB column as a table record. Then create a loop in the table to convert each record into XML data type. I have general idea on how to convert CLOB to XML. The difficult part to me is read the each entry in the text file to CLOB table. Please let me know what technique I should use. Any recommendation and sample code are welcome! I appreciate!
    Thanks,
    Bing
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>

    RBYL wrote:
    Hi,
    Thank you for your response. What I want to achieve is read the text file into ClOB column. There are hundreds reocords in the text file. The format is below. Each entry is '<DATALOAD (sensitive data here, use....... instead)</DATALOAD>' that needs to be read into clob table as a record. That is basically what I need to achieve.
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>
    hundreds of them here........
    <DATALOAD ................</DATALOAD>
    <DATALOAD ................</DATALOAD>So, is it really a text file or is it a well structured XML file?
    Just reading it into a CLOB to process is not likely to be the best way.
    If each line of the file is a record, then you're likely to be better using something like External Tables.
    If it's a structured XML file, then it can be read using CLOB functionality into an XMLTYPE datatype and then shredded down into relational table structures.
    Be more clear in what your requirements are and we can help you better.
    {message:id=9360002}

  • 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

  • Loading data from .csv file into existing table

    Hi,
    I have taken a look at several threads which talk about loading data from .csv file into existing /new table. Also checked out Vikas's application regarding the same. I am trying to explain my requirement with an example.
    I have a .csv file and I want the data to be loaded into an existing table. The timesheet table columns are -
    timesheet_entry_id,time_worked,timesheet_date,project_key .
    The csv columns are :
    project,utilization,project_key,timesheet_category,employee,timesheet_date , hours_worked etc.
    What I needed to know is that before the csv data is loaded into the timesheet table is there any way of validating the project key ( which is the primary key of the projects table) with the projects table . I need to perform similar validations with other columns like customer_id from customers table. Basically the loading should be done after validating if the data exists in the parent table. Has anyone done this kind of loading through the APEX utility-data load.Or is there another method of accomplishing the same.
    Does Vikas's application do what the utility does ( i am assuming that the code being from 2005 the utility was not incorporated in APEX at that time). Any helpful advise is greatly appreciated.
    Thanks,
    Anjali

    Hi Anjali,
    Take a look at these threads which might outline different ways to do it -
    File Browse, File Upload
    Loading CSV file using external table
    Loading a CSV file into a table
    you can create hidden items in the page to validate previous records before insert data.
    Hope this helps,
    M Tajuddin
    http://tajuddin.whitepagesbd.com

  • Error while inserting .doc file into CLOB object in oracle

    hello everybody ,
    i am trying to insert .doc file into clob column in oracle database.i am using oracle 8i. But i am getting error saying
    ORA-01461: can bind a LONG value only for insert into a LONG column
    i have no clue.
    i am pasting code here
    please help me out.
    regards
    darshan
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.Reader;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    public class InsertingClob {
    public static void main(String[] args) {
    File f = new File("E:\\dar
    sowres.doc");
    int len = (int) f.length();
    System.out.println(len);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
    FileReader fr = new FileReader(f);
    String FILE_INSERT_QUERY = "INSERT INTO RESUMED VALUES(?,?)";
    conn = JDBCUtility.getConnection();
    ps = conn.prepareStatement(FILE_INSERT_QUERY);
    ps.setString(1,"1");
    ps.setCharacterStream(2,fr,len);
    int result = ps.executeUpdate();
    if(result ==1) {
    System.out.println("file has been successfully inserted into the db");;
    }else {
    System.out.println("not inserted");
    }catch (Exception e) {
    e.printStackTrace();
    and the error is
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
    at InsertBlob.main(InsertBlob.java:21)
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

    You may have one of a few errors going for you there:
    The error says your column in Oracle is a Long not a CLOB, if it is, then make your column a CLOB.
    CLOB's are not suppored in all environments and/or all interfaces (specifically Windoz ODBC has a problem).
    I believe a DOC (Windoz MS-Word) file is a BLOB, due to formatting characters in the file.
    I had a very similar error using Access and trying to do this, but changing to SAS fixed the problem. It could very well be that your version of ODBC/JDBC drivers does not support it properly.

  • Getting Issue while uploading CSV file into internal table

    Hi,
    CSV file Data format as below
         a             b               c              d           e               f
    2.01E14     29-Sep-08     13:44:19     2.01E14     SELL     T+1
    actual values of column   A is 201000000000000
                     and  columen D is 201000000035690
    I am uploading above said CSV file into internal table using
    the below coding:
    TYPES: BEGIN OF TY_INTERN.
            INCLUDE STRUCTURE  KCDE_CELLS.
    TYPES: END OF TY_INTERN.
    CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
        EXPORTING
          I_FILENAME      = P_FILE
          I_SEPARATOR     = ','
        TABLES
          E_INTERN        = T_INTERN
        EXCEPTIONS
          UPLOAD_CSV      = 1
          UPLOAD_FILETYPE = 2
          OTHERS          = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    am getting all columns data into internal table,
    getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
    waiting for your reply...
    thanks & regards,
    abhi

    Hi Saurabh,
    Thanks for your reply.
    even i can't double click on those columns.
    b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
    regards,
    abhi

  • How to import old iPhone SMS.CSV file into new iPhone?

    Hey everyone,
    So I've spent a couple days on this as I just upgraded to the iPhone5S from my 4S.  Long story short, my backup restore didn't work after multiple tries (gave me the file is corrupt or not compatible with the iPhone error). 
    I tried:
    -reinstalling itunes
    -updating itunes
    -combining the 5S backup with the old 4S backup
    -tinyumbrella
    and a few of other things as I've forgot now.
    The most important things I needed was the contact list and SMS history.  I've got the contact list from extracting is successfully from the iTunes backup folder and using iCloud, but cannot figure out how to import the SMS.CSV file into my iPhone5S.
    Any suggestions on how I can get my SMS messages from my iPhone4s into my 5S?
    If anyone has any other suggestions on getting my Backup Restore to work that would be awesome too!
    Thanks!

    A word on SMS text messages. It is pracitcally impossible to import an SMS text-messages file to a new iPhone and have the Messages app on the new device read the messages.
    You can transfer, however contacts and other individual data (such as calendars and notes) from one iphone to the next. I had my old Nokia which whose contacts I exported to a CSV file. I then imported the file to my iphone which converted the file into multiple contacts in the Contacts app on the iphone. You can use a contact management app such as this one in order to import the contact file to the new iPhone.

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

  • Combine multiple CSV files into a single multi-column CSV file

    Hey Scripting Guy!
    I have what is probably a simple issue, but I haven't been able to find the right answer.
    I have 18 CSV files that each contain the same header and a single value as shown below:
    "Sum"
    "90"
    These files are the results of SMTP traffic by domain.
    All I want to do is to combine the 18 CSV files into a single file with the content of each file in a separate column, using the file name as the column header.
    For example:
    file1.csv
      "Sum"
      "90"
    file2.csv
      "Sum"
      "325"
    file2.csv
      "Sum"
      "3534"
    The desired ouput is:
    "file1.csv","file2.csv","file3.csv"
    "Sum","Sum","Sum"
    "90","325","3534"
    I don't need to row of Sum's if it is easy to leave out.  It would be even better if this could be put into an Excel spreadsheet.
    Thanks for your help!

    Can you post your script?
    If you are not a technician and do not want to write a script then you should try hiring a consultant.
    If you want to learn how to write a script then start here:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    By the way...your request makes no logical or technical sense.  What is the point of doing this?  There is no relationship between these files.
    ¯\_(ツ)_/¯

  • How To Split Large Excel or CSV Files into Smaller Files

    Does anyone know how to split a large Excel or CSV file into multiple smaller files?  Or, is there an app that will work with Mac to do that?

    split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]]
    is a native Terminal command. Read up more on https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/ man1/split.1.html
    I prefer to use gSplit which is gnu coreutils.
    You can install gnu coreutils using homebrew.

Maybe you are looking for

  • How to fix an error in sequnece setting (aspect ratio)?

    Hi, I have been working for a while on a project in CS4. I have created a sequence in it with an aspect ratio (AR) of 4:3 - worked for hours on it - but I should had the sequence created instead in 16:9. I realised it a bit too late... So how do I fi

  • Help needed : javamail Too many simultaneous connections

    Hello i'm using javamail to develop a webmail i've created a service Class , and all things works well , but i have a serious problem when i browse my webmail ( viewing folders: inbox / spam / etc or messages) i get an error saying : Too many simulta

  • Firefox is being slower than Internet Explorer since the update. Why?

    I updated Firefox, which is my absolute favorite browser, and it is being extraordinarily slow. I can't get anything done as far as working goes on my computer. I am currently running Chrome. Although that browser is faster than my car, it has few op

  • REP-1849    HELP!     Reports 6i runtime error message REP-1849

    Running Reports runtime 6 on Windows 2000 server. Printing to either printer from Notebook, prints OK. Printing to network HP LaserJet 8150 PL 6, all is OK Printing to network HP LaserJet 5Si MX this happens: The end of the trace log: 13:45:11 APP ..

  • Delete application list

    Anybody know how to delete application lists using the APEX API? For my application I need the ability to generate pages and navigation lists using the APEX API. I know there are the functions wwv_flow_api.create_list and wwv_flow_api.create_list_ite