CSV-Upload in ORACLE database

Hello,
I'm currently working on a workflow-project in Oracle APEX with an ORACLE database (10g) where - as a special feature - I have to implement a page where the User can upload a CSV - file into the database tables by himself.
The problem I have is that I don't find a way to fullfill the upload. Is there any special command in ORACLE or predefined scrip to upload a csv - file in an existing table like for example the MYSQL - command LOAD DATA INFILE?

Hi,
Just a quick question? are you trying to load data from the cvs or are you loading the file itself into a table. If you're to load data from the cvs then easier Sqlloader else if loading the file itself and Apex then the link will be helpful. or you use this example of web:
     CREATE TABLE my_docs
          (doc_id NUMBER,
          bfile_loc BFILE,
          doc_title VARCHAR2(255),
          doc_blob BLOB DEFAULT EMPTY_BLOB() );
     AS
PROCEDURE doc_dir_setup;
PROCEDURE list (in_doc IN VARCHAR2);
PROCEDURE load (in_doc IN VARCHAR2,
in_id IN NUMBER);
PROCEDURE search (in_search IN VARCHAR2,
in_id IN NUMBER);
END mydocs;
CREATE OR REPLACE PACKAGE BODY
mydocs
     AS
vexists BOOLEAN;
vfile_length NUMBER;
vblocksize NUMBER;
PROCEDURE doc_dir_setup IS
BEGIN
EXECUTE IMMEDIATE
'CREATE DIRECTORY DOC_DIR AS'||
'''"E:\jkoopmann\publish\databasejournal\Oracle"''';
END doc_dir_setup;
PROCEDURE list (in_doc IN VARCHAR2) IS
BEGIN
UTL_FILE.FGETATTR('DOC_DIR',
in_doc,
               vexists,
               vfile_length,
               vblocksize);
IF vexists THEN
dbms_output.put_line(in_doc||' '||vfile_length);
END IF;
END list;
PROCEDURE load (in_doc IN VARCHAR2,
in_id IN NUMBER) IS
temp_blob BLOB := empty_blob();
bfile_loc BFILE;
Bytes_to_load INTEGER := 4294967295;
BEGIN
bfile_loc := BFILENAME('DOC_DIR', in_doc);
INSERT INTO my_docs (doc_id, bfile_loc, doc_title)
VALUES (in_id, bfile_loc, in_doc);
SELECT doc_blob INTO temp_blob
FROM my_docs WHERE doc_id = in_id
FOR UPDATE;
DBMS_LOB.OPEN(bfile_loc, DBMS_LOB.LOB_READONLY);
DBMS_LOB.OPEN(temp_blob, DBMS_LOB.LOB_READWRITE);
DBMS_LOB.LOADFROMFILE(temp_blob, bfile_loc, Bytes_to_load);
DBMS_LOB.CLOSE(temp_blob);
DBMS_LOB.CLOSE(bfile_loc);
COMMIT;
END load;
-- in_id can be a db sequence---
PROCEDURE search (in_search VARCHAR2,
in_id NUMBER) IS
lob_doc BLOB;
Pattern VARCHAR2(30);
Position INTEGER := 0;
Offset INTEGER := 1;
Occurrence INTEGER := 1;
BEGIN
Pattern := utl_raw.cast_to_raw(in_search);
SELECT doc_blob INTO lob_doc
FROM my_docs WHERE doc_id = in_id;
DBMS_LOB.OPEN (lob_doc, DBMS_LOB.LOB_READONLY);
Position := DBMS_LOB.INSTR(lob_doc, Pattern, Offset, Occurrence);
IF Position = 0 THEN
DBMS_OUTPUT.PUT_LINE('Pattern not found');
ELSE
DBMS_OUTPUT.PUT_LINE('The pattern occurs at '|| position);
END IF;
DBMS_LOB.CLOSE (lob_doc);
END search;
BEGIN
DBMS_OUTPUT.ENABLE(1000000);
END mydocs;
How to Use
log into your database of choice as the SYS user
compile the package
     SQL> @mydocs.sql
set serveroutput on
     SQL> set serveroutput on
initial setup of directory object where your documents live
     SQL> exec mydocs.doc_dir_setup
Check to make sure you can read one of your documents on disk.
     SQL> exec mydocs.list('name.csv');
Load your document into the database
     SQL> exec mydocs.load('name.csv', 1);
Search your documents for a string pattern
     SQL> exec mydocs.search(Search Pattern', 1);
Regards,
Abby

Similar Messages

  • 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

  • Video Uploading in oracle database and playing that video in a jsf page

    Aoa,
    I want to upload videos in oracle database and I also want to play those videos using <af:media> tag in JDeveloper 11g. I have an applicaton which stores images in the database
    and show the images but when I try to upload videos lot of exceptions come.
    any suggestions / help

    Getting OracleMultimedia to work can be tricky. What kind of file are you trying to load into the database?

  • Parser - CSV files to Oracle database

    Hello all,
    I wrote a csv parser that parse csv files to micorsoft access database. Now I need to parse the dataset to oracle database. This is part of my exporter class
    class MdbExporter : IExporter
    /// <summary>
    /// Exportiert das DataSet in eine Mdb-Datei.
    /// </summary>
    /// <param name="ds">Zu exportierendes DataSet.</param>
    public void Write(DataSet ds, string[] names)
    string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" + names[0] + ";";
    Console.WriteLine("Exporting to database {0} ...", names[0]);
    Any ideas how can I do that?
    Thanks for any replay in advance.

    I wrote a parser that goes through several folders containing csv files, reads them and creates a dataset that contains 15 tables ( which I need for an intranet application after that). I succeed to write a MDB exporter that export this dataset to microsoft access database. Now I need an exporter that will export my dataset to ORACLE database. Below is the full code for my MDB exporter:
    public void Write(DataSet ds, string[] names)
    string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" + names[0] + ";";
    Console.WriteLine("Exporting to database {0} ...", names[0]);
    DbConnection connection = new OleDbConnection(conStr);
    try
    connection.Open();
    catch (DbException e)
    ConsoleEx.WriteException(true, e, "Unable to open database: {0}", names[0]);
    throw;
    DbCommand command = connection.CreateCommand();
    foreach (DataTable table in ds.Tables)
    Console.WriteLine("\tDeleting table: {0}", table.TableName);
    // delete old tables
    command.CommandText = string.Format("drop table {0}", table.TableName);
    TryExecute(command, false);
    // create new
    Console.WriteLine("\tCreating new table: {0}", table.TableName);
    string[] columnStrings = new string[table.Columns.Count];
    for (int i = 0; i < table.Columns.Count; i++)
    columnStrings[i] = "`" + table.Columns.ColumnName + "`" + " varchar";
    command.CommandText = string.Format("create table {0} ({1})",
    table.TableName, string.Join(", \n", columnStrings));
    TryExecute(command, true);
    // add rows
    for (int row = 0; row < table.Rows.Count; row++)
    for (int col = 0; col < table.Columns.Count; col++)
    columnStrings[col] = "'" + Convert.ToString(table.Rows[row].ItemArray[col]) + "'";
    command.CommandText = string.Format("insert into {0} values ({1})",
    table.TableName, string.Join(", \n", columnStrings));
    TryExecute(command, true);
    connection.Close();
    I need similar exporter to Oracle database. Starting with SQL LOADER from the beginning its really not a good in my opinion since I am almost done with this approach.
    Any help would be appreciated.
    Regards,
    Sven

  • Automate several table download in csv format from Oracle database

    Hi All,  I am new to Oracle database usage and currently using SQL Developer and PL/SQL for my day to day work.  Please help me with the below.
    Currently I am querying a table for few columns and using EXPORT facility from Query Result tab.  However, I want to do this for several tables.  If possible I would like to keep all these table downloads as overnight job.  Is there a way to do this?
    Thanks in advance.

    I guess you should post this in the SQL Developer forums. However; if you don't mind using other tools I have an idea: recently a feature has been added to the free mod_owa module to output a ref cursor in various formats; e.g. in CSV:
    https://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm#_refcur
    so in essence you'd need a stored procedure returning ref cursors and an apache with the module configured. You'd simply have to do HTTP Requests and store the response in a file.
    cheers

  • Data transfer from oracle database(external database) to sap database

    Hi Abapers,
    I have a requirment like excel data upload from oracle database(external database) to SAP database .Plz any one can help me how to create a bdc program for this requarment.
    Advance thanks you.
    Jnana

    HI
    use function module 'ASLM_EXCEL_TO_INTERNAL_TABLE' TO UPLOAD DATA FROM EXCEL SHEET TO INTERNAL TABLE. FROM THERE U CAN SAVE IT TO DATABASE USING BDC FUNCTION MODULES.

  • Csv upload fails when the header contains colon (:)

    Hi,
    There seem to be a problem with the csv upload to the database tables. If the column header of the csv file contains colon the process fails.
    Please help!!
    Mustak

    Hi Andy,
    Thanks! The APEX version is 2.0. I have developed an application where I uploading models and their features from the csv file. The csv file headers are models names, feature names etc and the rows are models and their corresponding features. Some of the features(as headers) contains colons such as "3:2-pulldown compensation", a feature of TV. The upload process reads the models and features and load the feature values to the appropriate table. So you can imagine the column headers are important for the process. I wander if there is any work around.
    Mustak

  • How to develope application for converting excel data into oracle database

    I am very new to the oracle world. I want to develop application for converting excel sheet into oracle database using oracle forms. I have basic knowldge of oracle but i am totally new to the forms. Can anybody tel me step by step procedure to do this task? Please help me out in this problem.
    Thanx in advance.

    Hello,
    just do a "Search" in this forum with words "excell to oracle"... and you could find lot of posts about that, i.e.:
    Re: How to load excel-csv file into oracle database
    Jose L

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

  • Error in uploading CSV (comma delimited) to database!!!!

    Hello,
    I'm karthik. We have a application with 10g database and we're using Ms-office 2007 in Windows XP system.
    While uploading csv files in Ms- office 2007 format it is good in uploading files to database.
    Most of our systems are upgraded to windows 7 and while we use Ms-office 2010 to do the same upload we found error in uploading.
    Its ora: ORA DATA NOT FOUND.
    So I uninstalled MS-office 2010 and installed Ms-Office 2007 and found some errors to do upload. The errors like some column is missing!!!
    Can you give me a way to fix these errors???????????

    You might be best to open a support incident about this so you can work directly with an engineer on this.  Infoview is using the Java SDK, its possible there is an issue with the .NET SDK that needs to be looked at.

  • Uploading data to an Oracle Database

    Hi there,
    We have an Oracle database and an application for data entry, etc. Some of my users do not want to use the data entry forms but would like to send us files either in text/xml to upload into our system. I have previously used text_id to parse text files and load them into a database, but am wondering if there is a better way of doing this either through web services, xml parsing, etc. If you've solved a similar problem using newer technologies, I would greatly appreciate your input.
    Thanks.
    Azeem.

    Hi Michel,
    Thank you so much for replying to my query. I have used SQL Loader in the past but since this is going to be an ongoing data transfer (load), I wanted to experiment with something new such as web services or XML. I think my users use XML and have expressed an interest in sending me XML files, that I would like to automatically load into the system. I'm not sure if I should provide them a forms interface to read their files, parse the data, and then upload it, and give them a bad file, or if I should look at something else.
    Thanks.
    Azeem.

  • Upload file in JSP with Oracle Database 10gR2

    How to upload file with oracle database 10gR2??
    i can't find how to upload..
    i've tried to create a procedure in oracle and execute in netbeans but the file save in directory and then from directory save to database.
    it means the file save in 2 location, in directory and database..
    does anybody know how to save file direct from the JSP file into database without save in directory?
    this is the procedure..
    create or replace PROCEDURE load_file (
    p_id number,
    p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('DIR_TEMP', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO temp_photo
    *(id, photo_name, photo)*
    VALUES
    *(p_id , p_photo_name ,EMPTY_BLOB())*
    RETURNING photo INTO dst_file;
    -- lock record
    SELECT photo
    INTO dst_file
    FROM temp_photo
    WHERE id = p_id
    AND photo_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE temp_photo
    SET photo = dst_file
    WHERE id = p_id
    AND photo_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;

    Well your Oracle procedure is designed to load a file, so that's what it does. If you want it to load from a data stream such as an upload, you need to rewrite it accordingly.
    So far this is not a Java question at all.

  • Upload pdf file in oracle database

    Hi Everyone,
    Can anybody describe me that how to upload/download pdf or doc file into oracle database using oracle form10g?
    Thanks in Advance.
    Baloch.

    Hello,
    The Webutil library has a FILE_TRANSFER package that includes functions to transfer file between the client machine, the Application Server and the Database.
    Francois

  • Upload data from Access Database to Oracle Database In oracle 8i

    hi everybody
    i am trying upload data from Access database to Oracle Database
    i have TT(F1,F2,F3) table in Access Databsse
    and emp(ename,ecode,sal) in oracle Database
    db_ac is my datasource name
    when i connect to Access Database thru this command this show following error
    SQL> connect a/a@odbc:db_ac;
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    ORA-00022: invalid session id; access denied
    Error accessing PRODUCT_USER_PROFILE
    Warning: Product user profile information not loaded!
    You may need to run PUPBLD.SQL as SYSTEM
    Server not available or version too low for this feature
    ORA-00022: invalid session id; access denied
    Connected.
    when i am trying copy data as this command it show error and data not copied.
    SQL> COPY FROM A/A@ODBC:DB_AC TO test/test@ora INSERT EMP USING SELECT F1,F2,F3 FROM TT;
    Array fetch/bind size is 15. (arraysize is 15)
    Will commit when done. (copycommit is 0)
    Maximum long size is 80. (long is 80)
    ORA-00022: invalid session id; access denied
    ERROR:
    OCA-00022: general OCA error
    can help me .
    with thanx

    Hi there,<br>
    <br>
    Please kindly use instead the Database Forum at:-<br>
    General Database Discussions<br>
    <br>
    ... to place your question as this is for the Oracle Portal product Export / Import functionality.<br>
    <br>
    <br>
    Kind regards,<br>
    Pedro.

Maybe you are looking for