You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by st...@gmail.com on 2006/02/07 07:33:21 UTC
dynamic insert question
Dear all,
I want insert the table via one dynamic select, the "PartVO" is one object
and it has "family" attribute, and it's type is "String",
<insert id="insertFamily" parameterClass="PartVO">
<![CDATA[
insert into cto.partfamily (family,partnum,parttype,active_flag) select
$family$,partnum,parttype,'N' from cto.partinfo where partnum in
]]>
<iterate property="domain" open="(" close=")" conjunction=",">
#domain[ ]#
</iterate>
</insert>
But it cause following error,seems the select can't get string value for
"family" column, but in the "PartVO" object, I already defined its type is
"String", and others are working(I use DB2 database):
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT]
SQL0408N A value is not compatible with the data type of its assignment
target. Target name is "FAMILY". SQLSTATE=42821
How can I make this function working?
Thanks so much for your warm-heated help!
Steven
Re: dynamic insert question
Posted by st...@gmail.com.
Dear Meindert,
After I add '', it's working. :=)
Thanks all for your warm-hearted help.
Steven
On 2/7/06, Meindert <me...@pastelebusiness.com> wrote:
>
> Hi Steven,
>
>
>
> The $family$ will do a literate replacement, so you would have to add ''
> (I think J) => '$family$'
>
> I would also advice to use the logging functionality to see the SQL
> statement created, make it much easier to see.
>
>
>
> *MEINDERT *
>
> *From:* stevenlou@gmail.com [mailto:stevenlou@gmail.com]
> *Sent:* 07 February 2006 08:33 AM
> *To:* user-java@ibatis.apache.org
> *Subject:* dynamic insert question
>
>
>
> Dear all,
>
>
>
> I want insert the table via one dynamic select, the "PartVO" is one object
> and it has "family" attribute, and it's type is "String",
>
>
>
> <insert id="insertFamily" parameterClass="PartVO">
> <![CDATA[
> insert into cto.partfamily (family,partnum,parttype,active_flag) select
> $family$,partnum,parttype,'N' from cto.partinfo where partnum in
> ]]>
> <iterate property="domain" open="(" close=")" conjunction=",">
> #domain[ ]#
> </iterate>
> </insert>
>
>
>
> But it cause following error,seems the select can't get string value for
> "family" column, but in the "PartVO" object, I already defined its type is
> "String", and others are working(I use DB2 database):
>
> Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT]
> SQL0408N A value is not compatible with the data type of its assignment
> target. Target name is "FAMILY". SQLSTATE=42821
>
>
> How can I make this function working?
>
>
>
> Thanks so much for your warm-heated help!
>
>
>
> Steven
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
>
RE: dynamic insert question
Posted by Meindert <me...@pastelebusiness.com>.
Hi Steven,
The $family$ will do a literate replacement, so you would have to add ‘’ (I
think :-)) => ‘$family$’
I would also advice to use the logging functionality to see the SQL
statement created, make it much easier to see.
MEINDERT
From: stevenlou@gmail.com [mailto:stevenlou@gmail.com]
Sent: 07 February 2006 08:33 AM
To: user-java@ibatis.apache.org
Subject: dynamic insert question
Dear all,
I want insert the table via one dynamic select, the "PartVO" is one object
and it has "family" attribute, and it's type is "String",
<insert id="insertFamily" parameterClass="PartVO">
<![CDATA[
insert into cto.partfamily (family,partnum,parttype,active_flag) select
$family$,partnum,parttype,'N' from cto.partinfo where partnum in
]]>
<iterate property="domain" open="(" close=")" conjunction=",">
#domain[ ]#
</iterate>
</insert>
But it cause following error,seems the select can't get string value for
"family" column, but in the "PartVO" object, I already defined its type is
"String", and others are working(I use DB2 database):
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0408N
A value is not compatible with the data type of its assignment target.
Target name is "FAMILY". SQLSTATE=42821
How can I make this function working?
Thanks so much for your warm-heated help!
Steven
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.2/251 - Release Date: 04/02/2006