PL/SQL program to read data from *.xls file into oracle tables

Posted on 2004-11-15
Last Modified: 2009-12-16

    I have a report data in the form of an   " *.xls "    file. The data in this file is of different languages
( eg:  english, japanese, taiwanese and chinese).

I wrote a ctrl file in PL/SQL to load the data from    *.csv  file into oracle tables and used  'sqlldr' to get my job done

But  Microsoft Excel is troubling us because
When I do save-As the *.xls  file into *.csv (comma seperated value format)
then all the character wrt japanese, taiwanese and chinese etc are lost and they are replaced with junk character like "????".

can U please suggest me

a)  As how to modify my ctrl file


b) write a new PL/SQL program,

so that it can read the data directly from " *.xls "   file into oracle tables without any data corruption ?
( i.e.  It should preserve the characters of different languages when exporting data from *.xls file into oracle tables).


Question by:gadenada
    LVL 9

    Accepted Solution

    make sure u used proper character set while loading csv to oracle.

    if u use external table using loader do not forget to specify characterset:
    CREATE DIRECTORY <your name of directory> as '<path to csv location on database server>';
    CREATE TABLE <your table name> (
      <col1>  VARCHAR2(1),
      <col2>  DATE,
    organization external(
    type oracle_loader
    default directory <your name of directory>
    access parameters( records delimited by newline characterset <your character set>
    skip 0
    badfile <your name of directory>:'<your csv filename>.bad'
    logfile <your name of directory>:'<your csv filename>.log'
    discardfile <your name of directory>:'<your csv filename>.discard'
    fields terminated by ';'
    enclosed by '"'    
      <col1>  CHAR(1),
      <col2>  DATE "YYYY/MM/DD",
    ) location( <your name of directory>:'<your csv filename>.csv'))

    if u use sql loader not using external table, make sure that user of operating system has set nls_ parameteter set to proper character set.
    LVL 13

    Expert Comment

    Just to be clear -- you won't load a Excel format file (.xls) created in Excel into Oracle via an external table (or any other method) you must convert to CSV prior to creating the external table, therefore option a) is the way to go.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
    This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now