Page 1 of 1

SUM on user-defined type

Posted: Mon Feb 29, 2016 8:03 am
by blambeau
Hi!

I'm just trying to get SUM(PARTS, WEIGHT) working with WEIGHT being "TYPE WEIGHT POSSREP {WEIGHT RATIONAL};"

I end up with

ERROR: RS0055: Could not find operator SUM(RELATION {PID P#, NAME NAME, COLOR COLOR, WEIGHT WEIGHT, CITY CHARACTER, %attributeName5 WEIGHT}, INTEGER)

I've tried defining OP_PLUS, but without much more success.

Any hint?

Thanks a lot,
Bernard

Re: SUM on user-defined type

Posted: Tue Mar 01, 2016 6:12 pm
by Dave
Try SUM(PARTS, THE_WEIGHT(WEIGHT))

Re: SUM on user-defined type

Posted: Tue Mar 01, 2016 6:33 pm
by blambeau
Lol, sure. But what if it makes sense to consider that WEIGHT + WEIGHT -> WEIGHT and I want to have SUM working out of the box?

Re: SUM on user-defined type

Posted: Tue Mar 01, 2016 7:18 pm
by Dave
Sorry, at present you can't, because the built-in aggregate operator SUM is only defined over INTEGER and RATIONAL.

A future update will support user-defined aggregate operators, which will permit defining SUM over user-defined types.