Glorp sum of production

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
vam
Reply | Threaded
Open this post in threaded view
|

Glorp sum of production

vam
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp sum of production

Alan Knight-2
q := Query read: OrderedItems where: [:each | each someInstanceVariable = 'someValue'].
q retrieve: [:each | each quantity * each item price].
session execute: q.

Except for the minor detail that glorp doesn't yet include arithmetic functions in the list of known functions. I've added them, and published the results as GlorpExpressions 7.7 - 5 + AR 56880 1

At 03:39 PM 4/8/2009, VAM wrote:

Hello!

I should get glorp query that will be equal next sql string:

select
  sum(Ordered_Items.quantity * items.price)
from
  Ordered_Items
join Items on Items.id = Ordered_Items.itemId
where
  Ordered_Items.someField = 'someValue'

How correctly make it with Glorp&
--
View this message in context: http://www.nabble.com/Glorp-sum-of-production-tp22957576p22957576.html
Sent from the VisualWorks mailing list archive at Nabble.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
vam
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp sum of production

vam
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp sum of production

Alan Knight-2
At 02:03 AM 4/9/2009, VAM wrote:
Alan,  I right understand  that this glorp query returns sum(each quantity * each item price)? And Can I load GlorpExpressions 7.7 - 5 + AR 56880 1 in VW7.6 or better add arithmetic functions in the list of known functions

Ah, no, that would return just the quantity * item price, not the sum. To return the sum you'd need

q retrieve: [:each | (each quantity * each item price) sum].

I think you should be able to load that version in 7.6, but if you can't, you can take the code change and add it yourself, it's just two lines of code added to createBasicFunctions...

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
vam
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp sum of production

vam
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Glorp sum of production

Alan Knight-2
I've published a version 7.7 - 60 + AR 46997 1

which allows this now.

At 11:18 PM 4/17/2009, VAM wrote:

Hi!



Alan Knight-2 wrote:
>
> I think you should be able to load that version in 7.6, but if you can't,
> you can take the code change and add it yourself, it's just two lines of
> code added to createBasicFunctions...
>

When I execute next query

query := Query read: OrderedItem where: [:each |  each item wholesale =
wholesale].
query retrieve: [:each | each quantity * 3].

then I get exception:

Unhandled exception: Message not understood: #mappedFields
Glorp.RelationExpression(Object)>>doesNotUnderstand:
Glorp.DataElementBuilder>>fieldsFromMyPerspective
Glorp.SimpleQuery>>computeFieldsFor:
optimized [] in Glorp.SimpleQuery>>computeFields
Array(SequenceableCollection)>>do:
Glorp.SimpleQuery>>computeFields
Glorp.SimpleQuery>>prepare
Glorp.SimpleQuery(Glorp.AbstractReadQuery)>>shortCircuitEmptyReturn:
Glorp.SimpleQuery>>rowsFromDatabaseWithParameters:
Glorp.SimpleQuery(Glorp.AbstractReadQuery)>>readFromDatabaseWithParameters:
Glorp.SimpleQuery(Glorp.AbstractReadQuery)>>executeWithParameters:in:
Glorp.GlorpSession>>execute:

--
View this message in context: http://www.nabble.com/Glorp-sum-of-production-tp22957576p23109042.html
Sent from the VisualWorks mailing list archive at Nabble.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc