Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using max in OCL

0 views
Skip to first unread message

Phil

unread,
Jan 2, 2006, 11:59:16 PM1/2/06
to
What would the OCL look like if I wish to obtain the max value of a column
that contains filename information (ie type varchar)?

Regards
Phil


Jonas Hogstrom [Borland]

unread,
Jan 11, 2006, 6:15:53 PM1/11/06
to
Phil wrote:

> What would the OCL look like if I wish to obtain the max value of a
> column that contains filename information (ie type varchar)?

File.allInstances->orderby(fileName)->first.fileName

it is not very efficient, but it should work. My standard disclaimer
regarding .allInstances applies as usual: Don't use it unless you
_know_ that the number of instances in the class will remain small (or
you use the OclPsHandle, but that does not apply in this case as it
does not support "->first").

/Jonas

Holger Flick

unread,
Jan 12, 2006, 1:22:44 PM1/12/06
to
Jonas Hogstrom [Borland] wrote:
> File.allInstances->orderby(fileName)->first.fileName

Erm. How do you define max in that case? Lexographical order?

--
Holger

Blog: http://delphi2006.blogspot.com

Jonas Hogstrom [Borland]

unread,
Jan 12, 2006, 2:00:50 PM1/12/06
to
Holger Flick wrote:

> Jonas Hogstrom [Borland] wrote:
> > File.allInstances->orderby(fileName)->first.fileName
>
> Erm. How do you define max in that case? Lexographical order?

It should probably have been "->last" and not "->first", and yes, it
will do string comparisons. The original question seemed to indicate
that there was a filename involved. The above would work just as fine
for a numeric attribute though.

/Jonas

0 new messages