db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamta Satoor <msat...@gmail.com>
Subject Re: Custom Bulk Import from CSV
Date Mon, 05 Nov 2012 20:24:17 GMT
Hi,

In addition to Rick's suggestion, I had another suggestion in case the
table in which you are imprting is not empty. I haven't tried this
myself but you can create a temporary table with one INTEGER column
and import the data from the cvs file into that table. Then insert
into your original table using that temporary table as follows
INSERT INTO originalTable(B,C)
	SELECT (fixedValueForB, *) FROM temporaryTable;

Mamta

On Mon, Nov 5, 2012 at 9:52 AM, Rick Hillegas <rick.hillegas@oracle.com> wrote:
> 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