I want to create a statement that performs inserts (or
updates, or creates tables) that can have the table
name as well as the number and type of the columns
determined at run time.
Assume a Map has two entries, tableName and records.
Records is a List of record objects. Record objects
have 3 values, fieldName, value and type. fieldName
is the name of the column, and type is the JDBC type
of the column. Value is always either a Date, Integer
(object, not primative), Long (object, not primative)
or String.
So assuming everything above, would the sqlMap segment
below work?
<insert id="insertRecord"
parameterClass="java.util.Map">
insert into $tableName$
<iterate open="(" close=")" conjunction=", ">
$records[].fieldName$
</iterate>
values
<iterate open="(" close=")" conjunction=", ">
#records[].value#:$records[].type$
</iterate>
</insert>
Thanks!
Rob
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com