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 Ashish Kulkarni <as...@gmail.com> on 2007/09/16 16:19:48 UTC

Dynamic Mapped Statements and Iterate question

Hi
I have a question about using Dynamic Mapped Statements and Iterate tag

I have a table with columns,
view
code
color

I have an sql statement like below which i have to convert to dynamic mapped
statement

select color from table where view=? and code in (?,?,?)

But the code in must be dynamic, for example user may select 3 code, or 100
code from the jsp select page.

How do i convert the above statement into Dynamic Mapped Statement, ( There
are 2 input parameters, view and code)


Ashish

Re: Dynamic Mapped Statements and Iterate question

Posted by Ashish Kulkarni <as...@gmail.com>.
Hi
I got it working

this is how i defined

<parameterMap id="getNotesMap" class="java.util.HashMap">
    <parameter property="view" javaType="java.lang.String" />
    <parameter property="notes" javaType="java.util.List" />
</parameterMap>

<select id="getNotesForScheduling" resultClass="java.util.HashMap"
                                            parameterMap="getNotesMap">

select * from table
<dynamic prepend="where">
      <iterate prepend="AND" property="notes" open="(" close=")"
                       conjunction="OR">
               code=#notes[]#
      </iterate>
and view =#view#
</dynamic>

</select>

</select>

On 9/16/07, Richard Yee <ry...@cruzio.com> wrote:
>
> Ashish,
> Did you read the documentation? What have you tried so far?
>
> -Richard
>
>
> Ashish Kulkarni wrote:
> > Hi
> > I have a question about using Dynamic Mapped Statements and Iterate tag
> >
> > I have a table with columns,
> > view
> > code
> > color
> >
> > I have an sql statement like below which i have to convert to dynamic
> > mapped statement
> >
> > select color from table where view=? and code in (?,?,?)
> >
> > But the code in must be dynamic, for example user may select 3 code,
> > or 100 code from the jsp select page.
> >
> > How do i convert the above statement into Dynamic Mapped Statement, (
> > There are 2 input parameters, view and code)
> >
> >
> > Ashish
> >
> >
>
>

Re: Dynamic Mapped Statements and Iterate question

Posted by Richard Yee <ry...@cruzio.com>.
Ashish,
Did you read the documentation? What have you tried so far?

-Richard


Ashish Kulkarni wrote:
> Hi
> I have a question about using Dynamic Mapped Statements and Iterate tag
>
> I have a table with columns,
> view
> code
> color
>
> I have an sql statement like below which i have to convert to dynamic 
> mapped statement
>
> select color from table where view=? and code in (?,?,?)
>
> But the code in must be dynamic, for example user may select 3 code, 
> or 100 code from the jsp select page.
>
> How do i convert the above statement into Dynamic Mapped Statement, ( 
> There are 2 input parameters, view and code)
>
>
> Ashish
>
>