using nextval in external udf I have a udf which returns a table. I was hoping to access the NEXTVAL
from a sequence to affect the logic flow and consequently the return
result. I'm using a LANGUAGE C type function.
Here's the fetch snippet
case SQLUDF_TF_FETCH:
/* fetch next row */
{
char * nextid = myrecids++;
char * ptr;
--pScratArea->recids_len;
if (pScratArea->recids_len < 1)
{
/* SQLUDF_STATE is part of SQLUDF_TRAIL_ARGS_ALL */
strcpy(outRecid, "");
strcpy(SQLUDF_STATE, "02000");
break;
}
// look for AM and terminate nextid
for (ptr = nextid; *ptr != '\376'; ++ptr) --pScratArea->recids_len;
*(ptr) = '\0';
myrecids = ptr + 1;
// copy current null terminated ptr to outRecid (return arg)
strcpy(outRecid, nextid);
}
*recidNullInd = 0;
/* next row of data */
pScratArea->file_pos++;
break;
What I'm hoping to do is use the result of a NEXTVAL call to cross
check against a counter in my scratch pad such that multiple process
can be feeding off this function table each row from the function table
would only be processed once. |