db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: How to import data from external csv (i had it in mysql !)
Date Thu, 01 May 2008 13:35:16 GMT
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
    (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,

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'), 
> 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 + "
> and it worked perfectly, not touching existing record in computer 'B'
> How obtain this with DERBY ?
> Thanks

View raw message