You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Eric Auer <er...@mpi.nl> on 2006/04/07 14:39:50 UTC

how to dump a single table to xml

Hi, I noticed that you can specify:

- the catalog(s)
- the schemas(s)
- the table TYPES

but not:

- the table names

in the DatabaseToDdlTask. I assume
that there is a typo in
http://db.apache.org/ddlutils/ant-tasks.html
and that this (and not "Same as for the
DdlToDatabaseTask task") is the flexibility
you get with writeDataToFile as well?

What I am trying to do is to dump a single
table from a database to some XML file.
The structure of the table can be dumped to
the same or a separate file. The dump of
the data should contain only the data of one
of the tables of the database.

How can this be done through the various
parameters of the Ant tasks? Or is it possible
to create a special Ant task to do this?
I would prefer to do the dump without having
to write a custom Java program to call DdlUtils.

Thanks for your suggestions...

Eric


Re: how to dump a single table to xml

Posted by Thomas Dudziak <to...@gmail.com>.
On 4/7/06, Eric Auer <er...@mpi.nl> wrote:

> Hi, I noticed that you can specify:
>
> - the catalog(s)
> - the schemas(s)
> - the table TYPES
>
> but not:
>
> - the table names
>
> in the DatabaseToDdlTask. I assume
> that there is a typo in
> http://db.apache.org/ddlutils/ant-tasks.html
> and that this (and not "Same as for the
> DdlToDatabaseTask task") is the flexibility
> you get with writeDataToFile as well?
>
> What I am trying to do is to dump a single
> table from a database to some XML file.
> The structure of the table can be dumped to
> the same or a separate file. The dump of
> the data should contain only the data of one
> of the tables of the database.
>
> How can this be done through the various
> parameters of the Ant tasks? Or is it possible
> to create a special Ant task to do this?
> I would prefer to do the dump without having
> to write a custom Java program to call DdlUtils.

The easiest solution for you right now would be to filter the
generated XML for your table via XSLT (using Ant's style task).
There is also a related feature request in DdlUtils' bug tracking system:

http://issues.apache.org/jira/browse/DDLUTILS-87

Tom

Re: how to dump a single table to xml

Posted by Eric Auer <er...@mpi.nl>.
Hi, to followup myself, I found that
ddlutils do have a notion of a table
name match pattern (note: the pattern is
case sensitive for quite a few database
vendors) but no "end user" interface to
select to-be-dumped databases. So I did
create the following ugly patch:

diff 
src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java{.org,}
50c50
<         setDefaultTablePattern(null);
---
 >         setDefaultTablePattern("mytable"); // EVIL!

Wildcards would be allowed here, too,
but I think you cannot write a list
of tables here? The pattern ends up
being passed to
java.sql.DatabaseMetaData.getTables
deeper inside ddlutils.

> Hi, I noticed that you can specify:
> 
> - the catalog(s)
> - the schemas(s)
> - the table TYPES
> 
> but not:
> 
> - the table names
> 
> in the DatabaseToDdlTask.
...
> What I am trying to do is to dump a single
> table from a database to some XML file.
...

Regards, Eric

PS: Maybe somebody can forward this to the
developer list and the DatabaseToDdlTask and
DdlToDatabaseTask can have a real user
interface for table selection in future
versions of ddlutils. Thanks!

PPS: I noticed that I had to use
ANT_OPTS=-Xmx1024M
to avoid running out of JVM heap space. The
processing was fast enough and the created
XML files are nice and clean, thank you :-).