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 "Celaya, Tina (GE Indust, ConsInd)" <ti...@ge.com> on 2006/07/27 19:49:00 UTC
problems with dynamic sql
I want to put somthing like this in de query moths in (1,2,3,4,5,6) and I tried using month in ($list$) and list have integers 1,2,3,4,5,6 but it doesnt work, i have an error that says invalid colum '1,2,3,4,5,6' and i dont know how to solve this so i can have this query
select * from table where months in (1,2,3,4,5) and year=year
i have this but is not working
<select id="nameID" parameterClass="java.util.Map" resultClass="someClass">
select * from table where months in ($months$) and year=#year#
and i sent a parameter hashmap than has hashmap.add("year",year) and hashmap.add("months",monthsList) and moths is a List with integers
thanks for your help
Tina Celaya
GE Consumer & Industrial
Systems Analyst
Re: problems with dynamic sql
Posted by Larry Meadors <lm...@apache.org>.
Look at the iterate stuff.
Larry
On 7/27/06, Celaya, Tina (GE Indust, ConsInd) <ti...@ge.com> wrote:
> I want to put somthing like this in de query moths in (1,2,3,4,5,6) and I tried using month in ($list$) and list have integers 1,2,3,4,5,6 but it doesnt work, i have an error that says invalid colum '1,2,3,4,5,6' and i dont know how to solve this so i can have this query
> select * from table where months in (1,2,3,4,5) and year=year
> i have this but is not working
>
> <select id="nameID" parameterClass="java.util.Map" resultClass="someClass">
> select * from table where months in ($months$) and year=#year#
>
> and i sent a parameter hashmap than has hashmap.add("year",year) and hashmap.add("months",monthsList) and moths is a List with integers
> thanks for your help
>
> Tina Celaya
> GE Consumer & Industrial
> Systems Analyst
>
>
>
>
RE: problems with dynamic sql
Posted by "Celaya, Tina (GE Indust, ConsInd)" <ti...@ge.com>.
Thank you very much, i´ll try ir with the iterate.
-----Original Message-----
From: Clinton Begin [mailto:clinton.begin@gmail.com]
Sent: Jueves, 27 de Julio de 2006 04:02 p.m.
To: user-java@ibatis.apache.org
Subject: Re: problems with dynamic sql
Yep. You want the <iterate> element for dynamic queries. It will help you avoid the risks of $substring$ replacement. The months value in the map should be a List or array[] of integers. The year shoudl be an integer or a string, depending on how your database is designed.
Cheers,
Clinton
On 7/27/06, Celaya, Tina (GE Indust, ConsInd) < tina.celaya@ge.com> wrote:
I want to put somthing like this in de query moths in (1,2,3,4,5,6) and I tried using month in ($list$) and list have integers 1,2,3,4,5,6 but it doesnt work, i have an error that says invalid colum '1,2,3,4,5,6' and i dont know how to solve this so i can have this query
select * from table where months in (1,2,3,4,5) and year=year
i have this but is not working
<select id="nameID" parameterClass="java.util.Map" resultClass="someClass">
select * from table where months in ($months$) and year=#year#
and i sent a parameter hashmap than has hashmap.add("year",year) and hashmap.add("months",monthsList) and moths is a List with integers
thanks for your help
Tina Celaya
GE Consumer & Industrial
Systems Analyst
Re: problems with dynamic sql
Posted by Clinton Begin <cl...@gmail.com>.
Yep. You want the <iterate> element for dynamic queries. It will help you
avoid the risks of $substring$ replacement. The months value in the map
should be a List or array[] of integers. The year shoudl be an integer or a
string, depending on how your database is designed.
Cheers,
Clinton
On 7/27/06, Celaya, Tina (GE Indust, ConsInd) <ti...@ge.com> wrote:
>
> I want to put somthing like this in de query moths in (1,2,3,4,5,6) and I
> tried using month in ($list$) and list have integers 1,2,3,4,5,6 but it
> doesnt work, i have an error that says invalid colum '1,2,3,4,5,6' and i
> dont know how to solve this so i can have this query
> select * from table where months in (1,2,3,4,5) and year=year
> i have this but is not working
>
> <select id="nameID" parameterClass="java.util.Map"
> resultClass="someClass">
> select * from table where months in ($months$) and year=#year#
>
> and i sent a parameter hashmap than has hashmap.add("year",year) and
> hashmap.add("months",monthsList) and moths is a List with integers
> thanks for your help
>
> Tina Celaya
> GE Consumer & Industrial
> Systems Analyst
>
>
>
>