Link to home
Start Free TrialLog in
Avatar of Spike_fr
Spike_fr

asked on

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

I'd like to convert a flat file to insert/update record in Oracle base using a script .sh file ?

Thanks in advance.

Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

Do you have sqlloader?
what is the file format?
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.
ASKER CERTIFIED SOLUTION
Avatar of BobMc
BobMc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial