How convert a flat file to Oracle with .ksh script ?

Posted on 2003-03-25
Medium Priority
Last Modified: 2012-08-13
I'd like to convert a flat file to insert/update record in Oracle base using a script .sh file ?

Thanks in advance.

Question by:Spike_fr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

by:Bruce Cadiz
ID: 8203885
Do you have sqlloader?
what is the file format?
LVL 35

Expert Comment

by:Mark Geerlings
ID: 8205908
If the flat file is just ASCII text data and it is either in fixed-length format, or delimitted, and if you have a table in Oracle you want the data loaded into, then Oracle's SQL*Loader is the tool to use.  You will need to write a control file for SQL*Loader (to map the fields in the text file to columns in the table) then you can write a shell script to call SQL*Loader and use the control file you wrote.

If the data is not clean or straitforward enough for SQL*Loader to handle directly into your target table, you will have to either laod into into a "work" table, then use SQL and/or PL\SQL to clean it up, then move it into your target table.  Or you can write a PL\SQL procedure that uses UTL_FILE to read the text file, clean up, transform or manipulate each record as needed, then insert it.

Either way, the table must exist in Oracle first.  Oracle does not provide a tool to create a table based on a plan text data file.

Accepted Solution

BobMc earned 200 total points
ID: 8206702
SqlLoader is normally the best bet for this type of load. However, if your flat file is not structured to suit, or requires a fair bit of manipulation, then I tend to use Perl rather than PL/SQL which tends to be a bit clumsy (or maybe thats just the way I write code!)


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Suggested Courses

770 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