You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Foth, Oliver" <Ol...@gedas.de> on 2001/10/10 13:29:01 UTC

criteria.addAscendingOrderBy - Problem!

Hi folks,

we have a problem with inserting a special ORDER BY. We try to generate the
following SQL-statement (excerpt):

... ORDER BY SUBSTR(TEILE.TNR,4,3),TEILE.TNR

Using	addAscendingOrderByColumn generates an error.
Any ideas on generating the statement with criteria?

rgds,

Oliver Foth

----------------------------------------------------
gedas deutschland GmbH
Teilelogistik
Team IDIS
Johann-Sigmund-Schuckert-Str. 2a, D-34225 Baunatal
Telefon/phone	+49-561-49995-34
Telefax/telefax	+49-561-49995-52
Mailto:oliver.foth@gedas.de
http://www.gedas.com
----------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: criteria.addAscendingOrderBy - Problem!

Posted by Bartek Walter <Ba...@man.poznan.pl>.
FO> Hi folks,

FO> we have a problem with inserting a special ORDER BY. We try to generate the
FO> following SQL-statement (excerpt):

FO> ... ORDER BY SUBSTR(TEILE.TNR,4,3),TEILE.TNR

FO> Using   addAscendingOrderByColumn generates an error.
FO> Any ideas on generating the statement with criteria?

I am not sure, but many databases (Oracle?) will treat such query as an
error since 'order by' cols must be 'select-ed' first.
Try this way:

select (...), SUBSTR(TEILE.TNR,4,3) as some_expression
from some_table
order by some_expression;

This one probably is easier to express in Criteria language
(criteria.addAsColumn() or similar)

Bartek Walter



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org