Hi,
I'm trying, inside a for loop, in Pro*C,
TO STORE the result of a fetch in an array,
but I don't want any repeated result in my result array (tableau_stockage in the example)
the following CODE doesnt WORK, a lot of identical data IS repeated.
How do i do that ? thanks IN advance
Code:int i, j; char v_period_name[1000]; CHAR tableau_stockage[MAX_TAB_PERIOD][20]; /* initialisation */ for(i = 0; i < 1000; i++) { v_period_name[i] = '\0'; } EXEC SQL BEGIN DECLARE SECTION; varchar v_period_name_l[1000][25]; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE cursor_1 CURSOR FOR SELECT myvalue FROM mytable; EXEC SQL OPEN cursor_1; while (1) { EXEC SQL FETCH cursor_1 INTO :v_period_name_l; for ( i = 0; i < Nb_Enr_Traites_Bloc; i++ ) { strncpy(v_period_name, (char *) v_period_name_l[i].arr, 16); v_period_name[16] = '\0'; for (j = 0; j < MAX_TAB_PERIOD; j++) { if (!(strcmp(tableau_stockage[j], v_period_name) == 0)) { if (tableau_stockage[j] == '\0'){ strcpy(tableau_stockage[j], v_period_name); tableau_stockage[j][16] = '\0'; } break; } } } /* end for */ }/* End while */ EXEC SQL CLOSE cursor_1;



LinkBack URL
About LinkBacks


