Solved

Sqlloader

Posted on 2014-09-14
2
191 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

919 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