background image
<< Examples of bulk import and export | CODESET values for import and export procedures >>

Running import and export procedures from JDBC

<< Examples of bulk import and export | CODESET values for import and export procedures >>
Derby Server and Administration Guide
77
The following example shows how to export data from the STAFF table to a delimited
data file,
myfile.del
, with the percentage character (
%
) as the character delimiter, and
a semicolon as the column delimiter from the STAFF table.
CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE(
null,'STAFF','c:\output\myfile.del',';','%',null);
Example: Exporting all data from a table, using a separate export file for the LOB
data
The following example shows how to export data from the STAFF table in a sample
database to the main file,
staff.del
, and the LOB export file,
pictures.dat
.
CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(null,'STAFF',
'c:\data\staff.del',',','"','UTF-8', 'c:\data\pictures.dat');
Example: Exporting data from a query to a single export file
The following example shows how to export employee data in department 20 from the
STAFF table in a sample database to the file
awards.del
.
CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY(
'SELECT * FROM STAFF WHERE dept=20',
'c:\output\awards.del',null,null,null);
Example: Exporting data from a query, using a separate export file for the LOB
data
The following example shows how to export employee data in department 20 from the
STAFF table in a sample database to the main file,
staff.del
, and the LOB data to the
file
pictures.dat
.
CALL SYSCS_UTIL.SYSCS_EXPORT_QUERY_LOBS_TO_EXTFILE(
'SELECT * FROM STAFF WHERE dept=20',
'c:\data\staff.del', ',' ,'"',
'UTF-8','c:\data\pictures.dat');
Running import and export procedures from JDBC
You can run import and export procedures from a JDBC program.
The following code fragment shows how you might call the
SYSCS_UTIL.SYSCS_EXPORT_TABLE procedure from a Java program. In this
example, the procedure exports the data in the
staff
table in the default schema to the
staff.dat
file. A percentage (
%
) character is used to specify the column delimiter.
PreparedStatement ps=conn.prepareStatement(
"CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE (?,?,?,?,?,?)");
ps.setString(1,null);
ps.setString(2,"STAFF");
ps.setString(3,"staff.dat");
ps.setString(4,"%");
ps.setString(5,null);
ps.setString(6,null);
ps.execute();
How the import and export procedures process NULL values
In a delimited file, a NULL value is exported as an empty field.
The following example shows the export of a four-column row where the third column is
empty:
7,95,,Happy Birthday