Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem on loading records from text files into the databases table

537341Jan 28 2007 — edited Jan 30 2007
Hi,
Good day to everyone here. Im using Hands-on Oracle Database 10g for Linux, now in page 228. Im having a problem of loading a text file into the databases table. Here is my databases table.

SQL> DESC handsonxe06.databases;
Name Null? Type
----------------------------------------- -------- ----------------------------
DB_ID NOT NULL NUMBER(3)
DB_NAME NOT NULL VARCHAR2(100)
DB_VERSION VARCHAR2(25)
HOST_ID NOT NULL NUMBER(3)

Now I have a text file called DB1.csv and I want to load this records into my databases table. Here is my text file.

db_name db_version host_id
db1 10.2.0.1 1
db2 9.2.0.7 1
db3 10.2.0.1 1
db4 10.2.0.1 1
db5 9.2.0.7 1
db6 9.2.0.7 1
db7 9.2.0.7 1
db8 9.2.0.7 1
I did not include the DB_ID because the data load will rely on the newly created DATABASES_TPK trigger (db_id sequence) to automatically generate primary keys for each new record.

Now after I loaded this records into the databases table, error messages showed up like this:

This page displays information about text data file import. If any rows failed while importing, this page displays an error message.
Import Date 28-JAN-07
Imported By HANDSONXE06
Schema HANDSONXE06
Table DATABASES
Rows Imported 0
Rows Failed 8

Failed Rows
Error Data
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 2: 'db1' '10.2.0.1' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 3: 'db2' '9.2.0.7' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 4: 'db3' '10.2.0.1' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 5: 'db4' '10.2.0.1' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 6: 'db5' '9.2.0.7' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 7: 'db6' '9.2.0.7' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 8: 'db7' '9.2.0.7' 1
ORA-01400: cannot insert NULL into ("HANDSONXE06"."DATABASES"."HOST_ID") Row 9: 'db8' '9.2.0.7' 1

I know I put data in the databases.host_id which is not null. Can anybody here explain to me what was really my big mistake in loading the records(DB1.csv) into the databases table. I would appreciate for some help please. Thank you very much.

regards,
jocelyn
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 27 2007
Added on Jan 28 2007
13 comments
495 views