Home » RDBMS Server » Server Utilities » SQL Loader - Unable to load data (ORACLE 11.1.0.6.0 WIN 8)
SQL Loader - Unable to load data [message #616029] |
Wed, 11 June 2014 13:46 |
anil_mk
Messages: 146 Registered: August 2006 Location: Bangalore, India
|
Senior Member |
|
|
Dear All,
I have created below table and tried to upload data from csv file but unable to load.
CREATE TABLE TEST_SQLLDR
(ID VARCHAR2(10),
NAME VARCHAR2(4000),
NUM VARCHAR2(40)
)
/
Below are the contents of control file
**************************************************************************************************
load data
infile 'D:\AMK\SQLLDR\TEST_SQLLDR.csv'
into table TEST_SQLLDR
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
(ID ,NAME,NUM)
**************************************************************************************************
Below is sqlldr command
D:\AMK\SQLLDR>sqlldr scott/tiger control=TEST_SQLLDR.ctl log=log1.log
/*
SQL*Loader: Release 11.1.0.6.0 - Production on Thu Jun 12 00:02:45 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Commit point reached - logical record count 54
*/
Above sqlldr command is running without any error but not inserting any data into table.
Please let me know how to handle multi-line data as in attached csv file.
Thanks,
Anil MK
[Updated on: Wed, 11 June 2014 13:51] Report message to a moderator
|
|
|
|
Re: SQL Loader - Unable to load data [message #616031 is a reply to message #616029] |
Wed, 11 June 2014 14:27 |
|
Barbara Boehmer
Messages: 9101 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
It looks like your newline character is different on your operating system than mine, but if your records are consistently 3 rows per record, then you can use CONCATENATE 3, as demonstrated below.
SCOTT@orcl12c> HOST TYPE test_sqlldr.csv
AB1234,"This is oracle db
This is sqlldr
",10
AB1234,"This is Oracle SQL.
Oracle stores more data.
",9B
AB1234,"This is oracle db
This is sqlldr
",12
AB1234,"This is Oracle SQL.
Oracle stores more data.
",14
CD8764,"This is oracle db
This is sqlldr
",16
CD8764,"This is Oracle SQL.
Oracle stores more data.
",19
CD8764,"This is oracle db
This is sqlldr
",20
CD8764,"This is Oracle SQL.
Oracle stores more data.
",22
EF8945,"This is oracle db
This is sqlldr
",24
EF8945,"This is Oracle SQL.
Oracle stores more data.
",26
EF8945,"This is oracle db
This is sqlldr
",28
EF8945,"This is Oracle SQL.
Oracle stores more data.
",30
SCOTT@orcl12c> HOST TYPE test_sqlldr.ctl
load data
infile 'TEST_SQLLDR.csv'
CONCATENATE 3
into table TEST_SQLLDR
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
(ID ,NAME,NUM)
SCOTT@orcl12c> CREATE TABLE TEST_SQLLDR
2 (ID VARCHAR2(10),
3 NAME VARCHAR2(4000),
4 NUM VARCHAR2(40)
5 )
6 /
Table created.
SCOTT@orcl12c> HOST sqlldr scott/tiger control=TEST_SQLLDR.ctl log=log1.log
SQL*Loader: Release 12.1.0.1.0 - Production on Wed Jun 11 12:23:49 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: Conventional
Commit point reached - logical record count 12
Table TEST_SQLLDR:
12 Rows successfully loaded.
Check the log file:
log1.log
for more information about the load.
SCOTT@orcl12c> COLUMN name FORMAT A45
SCOTT@orcl12c> COLUMN num FORMAT A10
SCOTT@orcl12c> SELECT * FROM test_sqlldr
2 /
ID NAME NUM
---------- --------------------------------------------- ----------
AB1234 This is oracle dbThis is sqlldr 10
AB1234 This is Oracle SQL.Oracle stores more data. 9B
AB1234 This is oracle dbThis is sqlldr 12
AB1234 This is Oracle SQL.Oracle stores more data. 14
CD8764 This is oracle dbThis is sqlldr 16
CD8764 This is Oracle SQL.Oracle stores more data. 19
CD8764 This is oracle dbThis is sqlldr 20
CD8764 This is Oracle SQL.Oracle stores more data. 22
EF8945 This is oracle dbThis is sqlldr 24
EF8945 This is Oracle SQL.Oracle stores more data. 26
EF8945 This is oracle dbThis is sqlldr 28
EF8945 This is Oracle SQL.Oracle stores more data. 30
12 rows selected.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: SQL Loader - Unable to load data [message #616085 is a reply to message #616082] |
Thu, 12 June 2014 04:11 |
anil_mk
Messages: 146 Registered: August 2006 Location: Bangalore, India
|
Senior Member |
|
|
Hi,
Please find SQL statements executed in same way as Barbara did.
SQL> HOST TYPE test_sqlldr.csv
AB1234,"This is oracle db
This is sqlldr
",10
AB1234,"This is Oracle SQL.
Oracle stores more data.
",9B
AB1234,"This is oracle db
This is sqlldr
",12
AB1234,"This is Oracle SQL.
Oracle stores more data.
",14
CD8764,"This is oracle db
This is sqlldr
",16
CD8764,"This is Oracle SQL.
Oracle stores more data.
",19
CD8764,"This is oracle db
This is sqlldr
",20
CD8764,"This is Oracle SQL.
Oracle stores more data.
",22
EF8945,"This is oracle db
This is sqlldr
",24
EF8945,"This is Oracle SQL.
Oracle stores more data.
",26
EF8945,"This is oracle db
This is sqlldr
",28
EF8945,"This is Oracle SQL.
Oracle stores more data.
",30
SQL> HOST TYPE test_sqlldr.ctl
load data
infile 'TEST_SQLLDR.csv'
CONCATENATE 3
into table TEST_SQLLDR
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
(ID ,NAME,NUM)
SQL> CREATE TABLE TEST_SQLLDR
2 (ID VARCHAR2
0),
3 NAME VARCHAR2(
00),
4 NUM VARCHAR2(40)
5 )
6 /
Table created.
SQL> HOST sqlldr scott/tiger control=TEST_SQLLDR.ctl log=log1.log
SQL*Loader: Release 11.2.0.3.0 - Production on Thu Jun 12 14:34:51 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 18
SQL>
Please find attached log.
Thanks,
Anil MK
-
Attachment: log1.log
(Size: 3.87KB, Downloaded 2371 times)
|
|
|
|
|
|
Re: SQL Loader - Unable to load data [message #616132 is a reply to message #616119] |
Thu, 12 June 2014 08:29 |
|
Barbara Boehmer
Messages: 9101 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
If the id column is consistently 6 characters with the 7th character a comma and there is no case where there is another line in the same data row where the 7th character is a comma, then you can use:
CONTINUEIF NEXT PRESERVE (7) != ','
as demonstrated below. If not, then you will need to find some other means of identifying where a record begins or ends. You may need to obtain your data in a different format.
SCOTT@orcl12c> HOST TYPE test_sqlldr.csv
AB1234,"This is oracle db
This is sqlldr
",10
AB1234,"This is Oracle SQL.
Oracle stores more data.
",9B
AB1234,"This is oracle db
This is sqlldr
",12
AB1234,"This is Oracle SQL.
Oracle stores more data.
",14
CD8764,"This is oracle db
This is sqlldr
",16
CD8764,"This is Oracle SQL.
Oracle stores more data.
",19
CD8764,"This is oracle db
This is sqlldr
",20
CD8764,"This is Oracle SQL.
Oracle stores more data.
",22
EF8945,"This is oracle db
This is sqlldr
",24
EF8945,"This is Oracle SQL.
Oracle stores more data.
",26
EF8945,"This is oracle db
This is sqlldr
",28
EF8945,"This is Oracle SQL.
Oracle stores more data.
",30
SCOTT@orcl12c> HOST TYPE test_sqlldr.ctl
load data
infile 'TEST_SQLLDR.csv'
CONTINUEIF NEXT PRESERVE (7) != ','
into table TEST_SQLLDR
fields terminated by ',' optionally enclosed by '"' TRAILING NULLCOLS
(ID ,NAME,NUM)
SCOTT@orcl12c> CREATE TABLE TEST_SQLLDR
2 (ID VARCHAR2(10),
3 NAME VARCHAR2(4000),
4 NUM VARCHAR2(40)
5 )
6 /
Table created.
SCOTT@orcl12c> HOST sqlldr scott/tiger control=TEST_SQLLDR.ctl log=log1.log
SQL*Loader: Release 12.1.0.1.0 - Production on Thu Jun 12 06:24:40 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: Conventional
Commit point reached - logical record count 11
Commit point reached - logical record count 12
Table TEST_SQLLDR:
12 Rows successfully loaded.
Check the log file:
log1.log
for more information about the load.
SCOTT@orcl12c> COLUMN name FORMAT A45
SCOTT@orcl12c> COLUMN num FORMAT A10
SCOTT@orcl12c> SELECT * FROM test_sqlldr
2 /
ID NAME NUM
---------- --------------------------------------------- ----------
AB1234 This is oracle dbThis is sqlldr 10
AB1234 This is Oracle SQL.Oracle stores more data. 9B
AB1234 This is oracle dbThis is sqlldr 12
AB1234 This is Oracle SQL.Oracle stores more data. 14
CD8764 This is oracle dbThis is sqlldr 16
CD8764 This is Oracle SQL.Oracle stores more data. 19
CD8764 This is oracle dbThis is sqlldr 20
CD8764 This is Oracle SQL.Oracle stores more data. 22
EF8945 This is oracle dbThis is sqlldr 24
EF8945 This is Oracle SQL.Oracle stores more data. 26
EF8945 This is oracle dbThis is sqlldr 28
EF8945 This is Oracle SQL.Oracle stores more data. 30
12 rows selected.
|
|
|
|
|
Re: SQL Loader - Unable to load data [message #616161 is a reply to message #616156] |
Thu, 12 June 2014 11:27 |
|
Barbara Boehmer
Messages: 9101 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
You must have used a different control file, because, according to your log file, you are using fields terminated by '^' not ',', so that would cause it to read past the comma in position 7 and try to read the whole line as part of the id. You need to provide a complete post as I did, including the data, control file, run, and the log file. It worked for me, so if it is not working for you, then it is because you are using something different, either different data or different control file or both.
|
|
|
|
|
Goto Forum:
Current Time: Mon Dec 23 03:04:03 CST 2024
|