Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Sqlloader

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
roy_sanu
Asked:
roy_sanu
2 Solutions
 
johnsoneSenior Oracle DBACommented:
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
 
Wasim Akram ShaikCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now