On Sat, Sep 16, 2006 at 03:47:28AM -0800, Poul Jensen wrote: > Thank you for your replies. My next attempt was: > > for (i=0; i<NVARS; i++) > { > sprintf(stmt,"SELECT %s FROM beamdata GROUP BY %s;",vars[i],vars[i]); > EXEC SQL EXECUTE IMMEDIATE :stmt; > n_occ[i] = sqlca.sqlerrd[2]; > } I've never used ECPG, but from the manual it seems the following should work: for (i=0; i<NVARS; i++) { sprintf(stmt,"SELECT %s FROM beamdata GROUP BY %s;",vars[i],vars[i]); EXEC SQL PREPARE mystmt FROM :stmt; EXEC SQL EXECUTE mystmt INTO wherever; n_occ[i] = sqlca.sqlerrd[2]; } I don't know what the n_occ line does, so I left it alone but maybe that needs changing too. Hope this helps, -- Martijn van Oosterhout <kleptog@xxxxxxxxx> http://svana.org/kleptog/ > From each according to his ability. To each according to his ability to litigate.
Attachment:
signature.asc
Description: Digital signature