Solved

Sqlloader

Posted on 2014-09-14
2
184 Views
Last Modified: 2014-10-11
Hi,

My columns is the database table do not map with the csv file,
I would like to move csv data col into oracle data base..

some of the columns in the csv file like ename1 are not exactly the name in the table column(ename)
so how i should go about as i donot want to change ename1, This is a small example which might help me
in resolving the project work... I have done some thing like this
 ename1 =>ename

here is the picec ctl file code, but it is  giving error as
SQL*Loader-350: Syntax error at line 6.
Expecting "," or ")", found "=".
   ( ename1 =>ename,


load data
   infile 'd:\ws\Book1.csv'
   into table emp
   fields terminated by "," optionally enclosed by '"'
   TRAILING nullcols
   ( empno =>empno,
     ename1 =>ename,
	 sal=> sal,
     deptno=>deptno
   )
   into table emp1
   fields terminated by "," optionally enclosed by '"'
   TRAILING nullcols
   ( empno 
     ename
     
   )

Open in new window

0
Comment
Question by:roy_sanu
2 Comments
 
LVL 34

Accepted Solution

by:
johnsone earned 250 total points
ID: 40321809
Columns in a CSV file are not referenced by name.  They don't actually have a name.  They are referenced by position.  The SQL*Loader control file, only contains the database column names.
0
 
LVL 16

Assisted Solution

by:Wasim Akram Shaik
Wasim Akram Shaik earned 250 total points
ID: 40324724
CSV headers doesn't have to do anything with the actual database table columns, they can be in any name you want,

you just have to map the database columns in the csv file and write the control file in such a way that it loads the database in corresponding columns, you can even skip the header record if you want.. there is a parameter (skip) which when included will skip the header record from the csv file

Sample illustration and syntax can be referred here
http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_skip_header_records_while_loading.3F

in your case you have to do modifications in your control file

this control file which you have posted in your example will do this

skip the header record and loads the data from the csv file named Book1.csv which is present in the location d:\ws into database table emp in the order mentioned below

options(skip=1) 
load data
   infile 'd:\ws\Book1.csv'
   into table emp
   fields terminated by ',' optionally enclosed by '"'
   TRAILING nullcols
   ( empno,
     ename,
     sal,
     deptno
   )

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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 how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

706 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

21 Experts available now in Live!

Get 1:1 Help Now