Home » RDBMS Server » Server Utilities » SQL*Loader - partial load where nulls not allowed problem
SQL*Loader - partial load where nulls not allowed problem [message #173178] Fri, 19 May 2006 23:18 Go to next message
gbell
Messages: 3
Registered: May 2006
Junior Member
Hi,

I'm trying to append into a table of 5 columns but only have 3 columns to load from the input file.

If I change the control file to remove the TRAILING NULLCOLS

I get this error
Record 1: Rejected - Error on table MSF010_TF, column XDATA.
Column not found before end of logical record (use TRAILING NULLCOLS)

Many thanks
Greg



Table

TABLE_TYPE NOT NULL CHAR(4)
TABLE_CODE NOT NULL CHAR(18)
TABLE_DESC NOT NULL CHAR(50)
ASSOC_REC NOT NULL CHAR(50)
XDATA NOT NULL CHAR(1)

Control File

LOAD DATA
INFILE 'msf010_tf.dat'
APPEND INTO TABLE MSF010_TF
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
(
TABLE_TYPE
, TABLE_CODE
, TABLE_DESC
, ASSOC_REC FILLER
, XDATA FILLER
)

Sample input data

TF|0101.10.00.0|-Pure-bred breeding animals||
TF|0101.90.10.0|--Race horses||
TF|0101.90.20.0|--Other horses||
TF|0101.90.90.0|--Other||
TF|0102.10.00.0|-Pure-bred breeding animals||
TF|0102.90.10.0|--Oxen||
TF|0102.90.20.0|--Buffaloes||
TF|0102.90.90.0|--Other||
TF|0103.10.00.0|-Pure-bred breeding animals||
TF|0103.91.00.0|--Weighing less than 50 kg||

Errors from logfile

Table MSF010_TF, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect

Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
TABLE_TYPE FIRST * | CHARACTER
TABLE_CODE NEXT * | CHARACTER
TABLE_DESC NEXT * | CHARACTER
ASSOC_REC NEXT * | CHARACTER
(FILLER FIELD)
XDATA NEXT * | CHARACTER
(FILLER FIELD)

Record 1: Rejected - Error on table MSF010_TF.
ORA-01400: cannot insert NULL into ("ELLIPSE"."MSF010_TF"."ASSOC_REC")

Record 2: Rejected - Error on table MSF010_TF.
ORA-01400: cannot insert NULL into ("ELLIPSE"."MSF010_TF"."ASSOC_REC")

Re: SQL*Loader - partial load where nulls not allowed problem [message #173180 is a reply to message #173178] Fri, 19 May 2006 23:31 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Looks like you are trying to insert a NULL value for ASSOC_REC into a NOT NULL column.
Re: SQL*Loader - partial load where nulls not allowed problem [message #173182 is a reply to message #173180] Sat, 20 May 2006 00:11 Go to previous messageGo to next message
gbell
Messages: 3
Registered: May 2006
Junior Member
Yes, you are correct. The problem is I don't have data for the last two columns and I can't modify the table's attributes. Within the application that uses this table the last two columns are not mandatory.

Any ideas?
Re: SQL*Loader - partial load where nulls not allowed problem [message #173206 is a reply to message #173182] Sat, 20 May 2006 04:42 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
How about inserting some constant dummy value if null is encountered?
oracle@mutation#cat somectl.ctl
LOAD DATA
infile 'somedata.data'
truncate INTO TABLE sometable
FIELDS TERMINATED BY "|"  trailing nullcols
(
table_type,
table_code,
table_desc,
assoc_rec "nvl(:assoc_rec,'DUMMYVALUE')",
xdata "nvl(:xdata,'D')"
)
oracle@mutation#sqlldr scott/tiger control=somectl.ctl

SQL*Loader: Release 9.2.0.4.0 - Production on Sat May 20 05:37:54 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Commit point reached - logical record count 10
oracle@mutation#sqlplus -s scott/tiger <<EOF
> set linesize 1000
> select * from sometable;
> exit;
> EOF

TABL TABLE_CODE         TABLE_DESC                                         ASSOC_REC                                          X
---- ------------------ -------------------------------------------------- -------------------------------------------------- -
TF   0101.10.00.0       -Pure-bred breeding animals                        DUMMYVALUE                                         D
TF   0101.90.10.0       --Race horses                                      DUMMYVALUE                                         D
TF   0101.90.20.0       --Other horses                                     DUMMYVALUE                                         D
TF   0101.90.90.0       --Other                                            DUMMYVALUE                                         D
TF   0102.10.00.0       -Pure-bred breeding animals                        DUMMYVALUE                                         D
TF   0102.90.10.0       --Oxen                                             DUMMYVALUE                                         D
TF   0102.90.20.0       --Buffaloes                                        DUMMYVALUE                                         D
TF   0102.90.90.0       --Other                                            DUMMYVALUE                                         D
TF   0103.10.00.0       -Pure-bred breeding animals                        DUMMYVALUE                                         D
TF   0103.91.00.0       --Weighing less than 50 kg                         DUMMYVALUE                                         D

10 rows selected.


In any case, this table will give you a lot of trouble.
Your are indiscriminately using CHAR and not null all over.
Waste of storage and bad peformance.
Re: SQL*Loader - partial load where nulls not allowed problem [message #173208 is a reply to message #173206] Sat, 20 May 2006 04:48 Go to previous message
gbell
Messages: 3
Registered: May 2006
Junior Member
Thanks for your reply. I ended up doing something very similar where I loaded one space in each of the columns.

All of the tables in the application are defined similarly, I don't know why. Thanks again.
Previous Topic: Problem using SUBSTR
Next Topic: Want help on SQL*Loader
Goto Forum:
  


Current Time: Thu Jul 04 20:22:16 CDT 2024