Second time fetch infinite cycle HELP!!!
Date: Mon, 22 Mar 1993 09:27:36 GMT
Message-ID: <1993Mar22.092736.14795_at_ul.pt>
HELP!!!! I'm programming an application with ORACLE and Motif.
I have a callback function, executed when the user presses a button, that does a SELECT and fills a listbox.
This works fine the first time that the function is executed, but the second time the user presses the button the function starts fetching the same row over and over and goes into an infinite loop; this row is the last one from the first time the function was called.
Can someone help ? The function is below... Thanx in advance.
void runquery(w,list,call_data)
Widget w;
Widget list;
caddr_t call_data;
{
int n,i;
Arg wargs[5];
XmString *xmstr;
EXEC SQL SELECT count(name) INTO :nitems FROM person; /* xmstr = (XmString *) XtMalloc(sizeof(XmString) * nitems ); */
EXEC SQL WHENEVER NOT FOUND GOTO fetch_end;
EXEC SQL DECLARE pnomecrsr CURSOR FOR
SELECT name
FROM person;
EXEC SQL OPEN pnomecrsr;
i=0;
for(;;)
{
EXEC SQL FETCH pnomecrsr INTO :name;
name.arr[name.len]='\0';
printf("%s\n",name.arr);
/* xmstr[i] = XmStringCreate( name.arr, XmSTRING_DEFAULT_CHARSET); */
i++;
}
fetch_end:
EXEC SQL CLOSE pnomecrsr;
EXEC SQL COMMIT WORK RELEASE;
/*
n = 0;
XtSetArg(wargs[n], XmNitems, xmstr); n++;
XtSetArg(wargs[n], XmNitemCount, nitems); n++;
XtSetValues(list,wargs,n);
for(i=0;i<nitems;i++)
XtFree(xmstr[i]);
*/
}
C U!
By(e)
Mario Valente Received on Mon Mar 22 1993 - 10:27:36 CET