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: Importing delimited files with header
Date Thu, 29 May 2008 16:00:22 GMT
Hi Patrick,

You can write a table function to help you out here. Your table function 
will open your file, throw away the header, and then loop through the 
lines in the file. I would recommend extending something like 
FlatFileVTI (in Derby's demo directory). You can look at PropertyFileVTI 
(in the same directory subtree), which will show you how to extend 
FlatFileVTI. Once you declare your table function (let's call it 
MyFileReader), you can then use it to populate your table as follows:

insert into STAFF
select * from table( MyFileReader( 'myfile.del' ) ) s

Hope this helps,

Patrick Meyer wrote:
> I have a comma delimited file that contains a header in the first row 
> of the file. The header contains column names. If I manually create a 
> new file without the header, I can successfully import the new file with
> SYSCS_UTIL.SYSCS_IMPORT_TABLE(null,'STAFF','myfile.del',null,null,null,0); 
> Creating the new file in my Java application is too time consuming for 
> it to be a good solution. Is there a way of importing a delimited file 
> with a header in the first row? Or, a way to import and ignore the 
> first row of the file being imported?
> Thanks

View raw message