db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: Custom Bulk Import from CSV
Date Mon, 05 Nov 2012 17:52:41 GMT
On 11/5/12 7:19 AM, Tom Deering wrote:
> I have a table that has the following columns:
>
> INTEGER A, INTEGER B, DATE C, FLOAT D, FLOAT E, FLOAT F, FLOAT G, 
> INTEGER H, FLOAT I
> A is my primary, auto-generated key
> B is a foreign key referencing the primary key of another table.
>
> I have a csv file containing many rows of data for columns C - I that 
> I would like to import with "CALL SYSCS_UTIL.SYSCS_IMPORT_DATA". All 
> rows of the csv file correspond to the same value for B. If be is left 
> unspecified, then I get:
>
> Column 'B'  cannot accept a NULL value.
>
> QUESTION: How can I bulk-import the data for columns C - I while 
> specifying the use of the same value for column B?
>
> Thanks in advance.
>
> -Tom-
>
Hi Tom,

The SYSCS_UTIL.SYSCS_IMPORT_DATA procedure lets you customize which 
columns of your table correspond to which columns in the csv file. It 
sounds as though column B is declared to be NOT NULL. The following 
might help you:

o Drop the table and recreate it without the NOT NULL constraint on 
column B.

o At the end of the import, bulk update the B column:

   update myTable set b = commonValueForB;

o Then turn the NOT NULL constraint on:

   alter table myTable alter column b not null;

Hope this helps,
-Rick

Mime
View raw message