ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <lmead...@apache.org>
Subject Re: Dynamic tables.
Date Tue, 01 Nov 2005 17:26:07 GMT
First off, DDL is unsupported. If it works, swell; If not, bummer.

You may be able to do the insert using $substitution$ and #parameters#
with iterate tags - I have never tried that, but give it a shot - it
may work.

Larry


On 11/1/05, David Moss <davidm@graticule.com> wrote:
> Hi,
>
> I'm trying to create a system that dynamically generates a table and
> inserts content according to the attributes of a dynamic data set (from
> imported files).  The data is actually from ESRI shape files, which
> require a table each for their attribute information.
>
> I believe that I've been able to set up the table as required with the
> following...
>
>     <update id="createGeomTable" parameterClass="VectorTableAttributes" >
>         create table #tableName# (#gid# serial
>         <iterate prepend="," property="columnNames" conjunction=",">
>             columnNames[] varchar
>         <iterate>
>         , CONSTRAINT #tableName#_pkey PRIMARY KEY (#gid#))
>     <update>
>
>     <update id="addGeomColumn" parameterClass="VectorTableAttributes" >
>         select
>     AddGeometryColumn('ecorisk',#tableName#,#geom#,'-1',#geometryType#,2)
>         <!--inserting data into a PostGIS database -->
>     </update>
>
>     <insert id="addGeometryTableEntry"
>     parameterClass="com.graticule.ecorisk.bus.beans.sets.VectorTableEntry">
>         insert into #tableName# (???????) values (??????) .......
>     </insert>
>
>
> However, I have a couple of questions...
>
>    1. Is it possible to combine several SQL statements into a single
>       <statement></statement> block?  e.g. could I combine
>       "createGeomTable" and "addGeomColumn" (I suspect not)?
>    2. What would be the best way of inserting the data.  As I don't know
>       the field names in advance I can't code them in.  I thought I
>       might be able to use a java.util.Map within VectorTableEntry to
>       map the column names to the column values but can't see how I
>       could get this to work.
>
>
>
> Any help / thoughts / experiences in this would be great.
>
> Ta!
>
> David.
>

Mime
View raw message