Multiple SQLDA in a module Not Working
Posted in 1998
Topics: General Discussion
Hello, I have an application that is using the sqlda structures for getting data out of the database. The problem I am running into is this. See below All works okay in the getTable1 function. I get these values in the daptr. $41 = {sqld = 48, sqlvar = 0x8c274, desc_name = "\\000\\b''", '\\000' <repeats 14 times>, desc_occ = 0, desc_next = 0x0} But in getTable2 $5 = {sqld = 8, sqlvar = 0x8c2a4, desc_name = "\\000\\b\\234 \\000\\000\\000\\000\\000\\b'P\\000\\000\\000\\000\\000\\000", desc_occ = 0, desc_next = 0x0} I only get 8 columns when I should have 62. Is there an unwritten rule where one can only use the sqlda once in a program? Thanks for any information. Cheers, Rob void getTable1() EXEC SQL BEGIN DECLARE SECTION; char cmd[SYNBUFSIZE]; char ttime[5]; char tdate[11]; int records; EXEC SQL END DECLARE SECTION; char selargs[SYNBUFSIZE]; sqlda *daptr; struct sqlvar_struct *colptr; omcBSC *ptrBSC; /* other stuff snipped */ sprintf(selargs," FROM cell_statistics WHERE date_val='%s' AND time_val='%s'",tdate,ttime); (void )infGetColumns(BSC,&selargs); /* build list of columns to get */ strcpy(cmd,selargs); EXEC SQL PREPARE bscobj from :cmd; EXEC SQL DESCRIBE bscobj into daptr; EXEC SQL DECLARE bCurs cursor for bscobj; EXEC SQL OPEN bCurs; EXEC SQL FETCH bCurs USING DESCRIPTOR daptr; /* code to the columns and move data */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~ * Free Informix Resources *~~~~~~~~~~~~~~~~~~~~~~~~~*/ EXEC SQL CLOSE bCurs; EXEC SQL free bscobj; EXEC SQL FREE bCurs; (void) free((char *) ptrBSC); (void) free((char *) daptr); (void) free(buffer); return; } /* end gettable1 void getTable2() { EXEC SQL BEGIN DECLARE SECTION; char cmd[SYNBUFSIZE]; char ttime[5]; char tdate[11]; int records; EXEC SQL END DECLARE SECTION; char selargs[SYNBUFSIZE]; sqlda *daeptr; struct sqlvar_struct *colptr; omcTcell *ptrTcell; /* other stuff snipped */ sprintf(selargs," FROM tcell_statistics WHERE date_val='%s' AND time_val='%s'",tdate,ttime); (void )infGetColumns(TCELL,&selargs); /* build list of columns to get */ strcpy(cmd,selargs); EXEC SQL PREPARE tcobj from :cmd; EXEC SQL DESCRIBE tcobj into daeptr; EXEC SQL DECLARE tCurs cursor for tcobj; EXEC SQL OPEN tCurs; EXEC SQL FETCH tCurs USING DESCRIPTOR daeptr; /* code to the columns and move data */ /*~~~~~~~~~~~~~~~~~~~~~~~~~~ * Free Informix Resources *~~~~~~~~~~~~~~~~~~~~~~~~~*/ EXEC SQL CLOSE tCurs; EXEC SQL free tcobj; EXEC SQL FREE tCurs (void) free((char *) ptrTcell); (void) free((char *) daeptr); (void) free(buffer); return; } /* end gettable2