Solved

Sqlloader

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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 Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

828 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