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 Jdev <da...@telenet.be> on 2007/08/06 15:11:59 UTC

Question using order by

Is there really nobody who can help me using an order by?
I have searched on the Internet but I can find nothing useful.
I have post this question a couple of days ago, but I have got still no answer.

--------------------------------------------


I have the following query which must be converted to Ibatis.
But I don’t know how I must write the SUBSTR and DESC in Ibatis

private final String select1 =
        "SELECT refnumber, rownumber, begindate, enddate, officenumber, " +
FROM " + ConnectDB.schema1 + ".office " +
        "WHERE refnumber LIKE ? " +
        "ORDER BY substr(refnumber,16,12) DESC, refnumber, begindate DESC ";

Abator has everything generated and everything works perfectly, except I don’t know how to write the query in the Ibatis xml file for SUBSTR and DESC.
Below a small query what Abator has generated and the query mentioned below must be extended to what above stands.
Can someone explain me how or what is the best way to process the above query to my new Ibatis query mentioned below.

<select id="………etc….
select refnumber, rownumber, begindate, enddate, officenumber
    from ${schema1}.office
<isParameterPresent>
      <include refid="office.abatorgenerated_Example_Where_Clause"/>
      <isNotNull property="orderByClause">
        order by $orderByClause$
      </isNotNull>
    </isParameterPresent>
  </select>


Thank you in advance,
Davy



Re: Question using order by

Posted by Richard Yee <ry...@cruzio.com>.
Have you tried putting

select refnumber, rownumber, begindate, enddate, officenumber
    from ${schema1}.office
<isParameterPresent>
      <include refid="office.abatorgenerated_Example_Where_Clause"/>
      <isNotNull property="orderByClause">
      </isNotNull>
    </isParameterPresent>
ORDER BY substr(refnumber,16,12) DESC, refnumber, begindate DESC

  </select>

in your SQL map? You haven't really explained what error or problem you are having. That is probably why no one is responding. Are you getting any errors?

-Richard





Jdev wrote:
> Is there really nobody who can help me using an order by?
> I have searched on the Internet but I can find nothing useful.
> I have post this question a couple of days ago, but I have got still no answer.
>
> --------------------------------------------
>
>
> I have the following query which must be converted to Ibatis.
> But I don’t know how I must write the SUBSTR and DESC in Ibatis
>
> private final String select1 =
>         "SELECT refnumber, rownumber, begindate, enddate, officenumber, " +
> FROM " + ConnectDB.schema1 + ".office " +
>         "WHERE refnumber LIKE ? " +
>         "ORDER BY substr(refnumber,16,12) DESC, refnumber, begindate DESC ";
>
> Abator has everything generated and everything works perfectly, except I don’t know how to write the query in the Ibatis xml file for SUBSTR and DESC.
> Below a small query what Abator has generated and the query mentioned below must be extended to what above stands.
> Can someone explain me how or what is the best way to process the above query to my new Ibatis query mentioned below.
>
> <select id="………etc….
> select refnumber, rownumber, begindate, enddate, officenumber
>     from ${schema1}.office
> <isParameterPresent>
>       <include refid="office.abatorgenerated_Example_Where_Clause"/>
>       <isNotNull property="orderByClause">
>         order by $orderByClause$
>       </isNotNull>
>     </isParameterPresent>
>   </select>
>
>
> Thank you in advance,
> Davy
>
>
>
>