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 Peter Cai <pe...@yahoo.com.cn> on 2005/03/02 22:58:58 UTC
fill SQL string variable without single quotes
Hi,
I used this mapping to get the schema information for a table:
<parameterMap id="select-field-para" class="fieldParameter">
<parameter property="table" />
<parameter property="schema" />
</parameterMap>
<statement id="getFieldList" parameterMap="select-field-para">
show columns from ? from ?
</statement>
when I set table="product" schema="jpetstore" in fieldParameter class (both
schema and table are java String type). I really want a sql statement like
this
" show columns from product from jpetstore "
But iBATIS will generate a statement like this:
" show columns from 'product' from 'jpetstore' "
So MySQL database always complaint an error.
How to fix it?
Thank you very much!
Peter
Re: fill SQL string variable without single quotes
Posted by Larry Meadors <la...@gmail.com>.
Use substitution instead:
<statement id="getFieldList">
show columns from $table$ from $schema$
</statement>
It is in the users guide...
Larry
On Wed, 2 Mar 2005 16:58:58 -0500, Peter Cai <pe...@yahoo.com.cn> wrote:
>
> Hi,
>
> I used this mapping to get the schema information for a table:
>
>
> <parameterMap id="select-field-para" class="fieldParameter">
> <parameter property="table" />
> <parameter property="schema" />
> </parameterMap>
>
> <statement id="getFieldList" parameterMap="select-field-para">
> show columns from ? from ?
> </statement>
>
>
>
> when I set table="product" schema="jpetstore" in fieldParameter class (both
> schema and table are java String type). I really want a sql statement like
> this
>
> " show columns from product from jpetstore "
>
> But iBATIS will generate a statement like this:
>
> " show columns from 'product' from 'jpetstore' "
>
> So MySQL database always complaint an error.
>
> How to fix it?
>
> Thank you very much!
>
> Peter
>
>