Igor Tandetnik,
>> How come you only show one function? A user-defined aggregate function is
>> actually represented by two C[++] functions - one that is called for every
>> row
>> and performs actual aggregation, and another that's called at the end of
>> each
>> group, reports the result and resets the state machine to prepare for the
>> next
>> group. You can use sqlite3_context to store state between invocations - see
>> sqlite3_aggregate_context.
We have defined 2 C++ function XStep and XFinalize(shown below).
The group by last name BLOB results look accurate. Thank you for your help.
void cIntersectingGroupCache::XFinalize(sqlite3_context *context){
listCtx *p;
char *buf=NULL;
buf = (char *) malloc ((sizeof(int) *
((cIntersectingGroupCache*)(p->TheThis))->Column2.size())+ 4);
if (buf == NULL)
printf("malloc error in XFinalize, buf\n");
sqlite3_result_blob(context,buf,
(((cIntersectingGroupCache*)(p->TheThis))->Column2.size()*sizeof(int))
+ 4, free);
((cIntersectingGroupCache*)(p->TheThis))->Column2.clear();
}
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users