#define BUFFER_SIZE 10000
/* Aggregate intermediate record */
typedef struct
{
FNC_LobLength_t length;
LOB_REF ref;
BYTE prefix[500];
} intrec_t;
void Max_Blob(FNC_Phase phase,
FNC_Context_t *fctx,
LOB_LOCATOR *x,
LOB_RESULT_LOCATOR *result,
int *x_i,
int *result_i,
char sqlstate[6])
{
intrec_t *s1 = (intrec_t*) fctx->interim1;
LOB_CONTEXT_ID id;
FNC_LobLength_t actlen;
switch (phase)
{
case AGR_INIT:
...
case AGR_DETAIL:
...
break;
case AGR_FINAL:
FNC_LobOpen(*(FNC_LobRef2Loc(&s1->ref)), &id, 0, 0);
FNC_LobRead(id, buffer, BUFFER_SIZE, &actlen);
FNC_LobAppend(*result, buffer, actlen, &actlen);
FNC_LobClose(id);
break;
...
}
For a complete example that uses FNC_LobRef2Loc, see C Aggregate Function Using LOBs.