URGENT: HELP --- Select and Insert into the same table ?
Posted in 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