db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MikeRam <ing.ramu...@tiscali.it>
Subject Re: How to import data from external csv (i had it in mysql !)
Date Fri, 02 May 2008 16:20:05 GMT

Thanks for your reply i will try, even if it's not an elegant solution.
:handshake:

Rick Hillegas-2 wrote:
> 
> 
> 
> 
> Hi Mike,
> 
> One solution would be to do this:
> 
> 1) Create a dummy table with the same shape as your target table
> 2) Import the data into the dummy table
> 3) Copy from the dummy table into the target table but specify that you 
> only want rows which won't generate collisions.
> 
> Something like this:
> 
> -- create a dummy table with the same shape as your target table
> create table dummy as select * from targetTable with no data;
> 
> -- import all of the data into the dummy table
> CALL SYSCS_UTIL.SYSCS_IMPORT_DATA
>     (NULL, 'DUMMY', null, null, 'data.del', null, null, null,0);
> 
> -- copy only the data which won't generate key collisions
> insert into targetTable
> select * from dummy
>    where dummy.keyCol not in ( select keyCol from targetTable );
> 
> -- discard the dummy table
> drop table dummy;
> 
> 
> Hope this helps,
> -Rick
> 
> 
> MikeRam wrote:
>> I have exported record from a Derby DB (whit a primary unique ID) on
>> computer
>> 'A' in a csv data file
>> whith the command CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY .....
>> but when i import them in an other equal derby database (on computer
>> 'B'), 
>> whit the command CALL SYSCS_UTIL.SYSCS_IMPORT_DATA,
>> i receive an exception because of the presence of records whith the same
>> ID
>> (primary unique).
>> i want only add records not present on computer 'B'. I don't want REPLACE
>> all the record
>> (if i import data whit this option set i dont'receive exception, but i
>> don't
>> want this !!!)
>> I'm migrating from mysql and i used the query
>> LOAD DATA INFILE '"+ FileSelezionato + "' IGNORE INTO TABLE " + Tb + "
>> FIELDS TERMINATED BY ','"
>> and it worked perfectly, not touching existing record in computer 'B'
>> How obtain this with DERBY ?
>> Thanks
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-import-data-from-external-csv-%28i-had-it-in-mysql-%21%29-tp16993202p17022883.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message