Thought inc.

The Dynamic O/R Mapping Company
     

CocoBase Technical Support Forums
For access to developer site with software download and doc's, please request CocoBase download and password
will be emailed to you. Response to posts will appear when answered by THOUGHT Support team.
NOTE:You must register separately with forum in order to post your questions, please click on register icon below.
Home   Frequently Asked Questions   Search   Edit your profile   Registration is free!  
Email This Page to Someone!
Show a Printable Version
CocoBase Enterprise O/R Forums > CocoBase Questions
OrderBy
< Previous Thread     Next Thread >
Author
Thread    Post New Thread     Post A Reply
jwright4105
Member

Registered: Jan 2002
Posts: 1

Greetings,

I am currently using a GenPObject to select from a database and I am working on a dynamic sorting mechanism. I can dynamically sort by specifying the table.columnname, but I was wondering if there is an easy way to do this with the actual field name.

The more concrete example is I am sorting on orderinfo.orderid which maps to :ID and I was hoping to setOrderBy("ID") somehow rather than having to specify the table name, etc. Thanks in advance!

James Wright

01-14-2002 02:49 PM
Click Here to See the Profile for jwright4105    Find more posts by jwright4105        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

You can specify this in the map by adding a where condition
with no operand or conjunctive and a RHS value of only the
order by clause included. That design assumes that you wish
to have the same order by every time...

The other option is to use the QueryBuilder to transpose
the name for you. You can specify the field label, and
it will return the field name. So for example if your
column name is orderid but your java attribute is simply
id. Then your code could look like:

QueryBuilder qb = new QueryBuilder();
qb.setFieldTranslation(myBase.getColumns("Orderinfo"));
String colName = qb.processFieldName("ID");

The version of the query builder we ship can be found in
the demos\pguide\querying, and by default processFieldName
is a private method, but you can easily change it to public,
and recompile it for this functionality.

THOUGHT Support

01-14-2002 04:23 PM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
fsilva
Member

Registered: Mar 2004
Posts: 18

Hi,
I need to specify my order by clause direct in the map, as you said; I just added a where condition with no operand or conjunctive and a RHS value of only the order by clause included.
But when I don't specify other field in the where clause, I've got the generated SQL:
CocoPowder:: query = select F1,F2,F3,F4,F5,F6,F7,F8,F9,F10 from (SELECT MKL_HISTORICO.ID AS F1,MKL_HISTORICO.DATA_LIBERACAO AS F2,MKL_HISTORICO.DATA_CRIACAO AS F3,MKL_HISTORICO.TITULO AS F4,MKL_HISTORICO.DESCRICAO AS F5,MKL_HISTORICO.SOLUCAO AS F6,MKL_HISTORICO.IND_MANUAL AS F7,MKL_HISTORICO.STATUS AS F8,MKL_HISTORICO.PRF_RESP_CODIGO AS F9,MKL_HISTORICO.ORIENTACOES_CONSULT AS F10 FROM MKL_HISTORICO WHERE order by null DATA_CRIACAO DESC) T0
CocoPowder:: Creating new Prepared SQL Statement
CocoPowder:: Exception encountered = java.sql.SQLException: ORA-00936: missing expression

How can I solve this issue?
Thanks.

08-11-2004 01:04 PM
Click Here to See the Profile for fsilva    Find more posts by fsilva        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

Why does it say 'order by null'? Is that what you encoded in the map? What does the 'encoding' look like in your where clause?

THOUGHT Support

08-11-2004 01:14 PM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
fsilva
Member

Registered: Mar 2004
Posts: 18

It is exactly what I need to know...Why does it say 'order by null'?
In my map, I just added a where condition with no operand or conjunctive and a RHS value of only the order by clause included. My RHS value is "order by DATA_CRIACAO DESC" and my Resulting SQL Map is:
select
MKL_HISTORICO.ID,
MKL_HISTORICO.DATA_LIBERACAO,
MKL_HISTORICO.DATA_CRIACAO,
MKL_HISTORICO.TITULO,
MKL_HISTORICO.DESCRICAO,
MKL_HISTORICO.SOLUCAO,
MKL_HISTORICO.IND_MANUAL,
MKL_HISTORICO.STATUS,
MKL_HISTORICO.PRF_RESP_CODIGO,
MKL_HISTORICO.ORIENTACOES_CONSULT
from
MKL_HISTORICO
where

MKL_HISTORICO.ID = :ID
AND MKL_HISTORICO.DATA_LIBERACAO = :DATA_LIBERACAO
AND MKL_HISTORICO.DATA_CRIACAO = :DATA_CRIACAO
AND MKL_HISTORICO.TITULO = :TITULO
AND MKL_HISTORICO.DESCRICAO = :DESCRICAO
AND MKL_HISTORICO.SOLUCAO = :SOLUCAO
AND MKL_HISTORICO.IND_MANUAL = :IND_MANUAL
AND MKL_HISTORICO.STATUS = :STATUS
AND MKL_HISTORICO.PRF_RESP_CODIGO = :PRF_RESP_CODIGO
AND MKL_HISTORICO.ORIENTACOES_CONSULT = :ORIENTACOES_CONSULT
order by DATA_CRIACAO DESC

How Can I solve this issue?
Thanks.

08-12-2004 12:54 PM
Click Here to See the Profile for fsilva    Find more posts by fsilva        Edit/Delete Message    Reply w/Quote    IP: Logged
admin
Administrator

Registered: Apr 2001
Posts: 19

The first thing to do is to send us the full debug log file. Also are you using the latest Service Release 6 edition? It's possible this is something that was already handled in SR6.

If you can send the debug file, the map, and the code fragment you use to issue the query along with any connection parameter settings you might be using we can see if we can reproduce this.

And please confirm if possible if this is still a problem in SR6.

THOUGHT Support

08-12-2004 01:11 PM
Click Here to See the Profile for admin    Find more posts by admin        Edit/Delete Message    Reply w/Quote    IP: Logged
All times are PST (US)    Post New Thread     Post A Reply
Forum Jump:
< Previous Thread     Next Thread >

Forum Rules:
Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author. Messages can be deleted by their author.
Posts: HTML code is OFF. Smilies are OFF. vB code is OFF. [IMG] code is OFF.

Admin Options:
Open / Close Thread
Move Thread
Delete Thread
Edit Thread

< Contact Us - THOUGHT Inc. >

Copyright © Jelsoft Enterprises Limited 2000.
Copyright 2001 All Rights Reserved, THOUGHT Inc.