Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Renaud MARTIAL — — source: Informix-list mailing list archive (1991-1998)
Hi,
In ESQL/C, is it possible to insert rows into the same table which is
fetched within a cursor loop ?
ie. can the following code work ??
---------------------------------------
EXEC SQL DECLARE curs WITH HOLD FOR "select n from toto";
while(1) {
EXEC SQL FETCH curs INTO $n;
if( SQLCODE != 0) {
break;
}
sprintf(szBuff, "insert into toto(n) values %d", n * 2);
EXEC SQL PREPARE statement FROM $szBuff;
EXEC SQL BEGIN WORK;
EXEC SQL EXECUTE statement;
if( SQLCODE != 0) {
EXEC SQL ROLLBACK WORK;
break;
}
else {
EXEC SQL COMMIT WORK;
}
}
EXEC SQL CLOSE curs;
EXEC SQL FREE curs;
---------------------------------------
Thank you
(please, answer also to csii@iway.fr)
Renaud MARTIAL
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.