1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| SQL_CODE BdbR_poste_parcours_TOTO_Extraire(s_LISTE_poste_PARCOURS_TOTO **r_liste_poste_parcours_TOTO)
{
exec sql whenever sqlwarning continue;
exec sql whenever sqlerror continue;
exec sql whenever not found continue;
exec sql begin declare section;
poste_PARCOURS_TOTO w_poste_parcours_TOTO;
exec sql end declare section;
s_LISTE_poste_PARCOURS_TOTO *w_liste_poste_parcours_TOTO_premier = NULL ;
s_LISTE_poste_PARCOURS_TOTO *w_liste_poste_parcours_TOTO_courant = NULL ;
SQL_CODE sqlcode = NOT_FOUND ;
long nb = 0;
#ifdef NOM_FONCTION
#undef NOM_FONCTION
#endif
#ifdef TRACE
#define NOM_FONCTION "BdbR_poste_parcours_TOTO_Extraire"
ENTREE_FONCTION;
#endif
/* execution de la requete */
exec sql declare curseur_liste_poste_parcours_TOTO cursor
for
select r_int_poste,r_dda,r_dfa,r_int_canton,r_int_noeudv,r_n_aiguille,r_position from r_poste ,r_iti_canton , r_iti_aig_inter
where r_int_poste=r_int_poste and r_int_poste=r_int_poste and r_int_poste=r_int_poste
order by r_int_poste,r_rang;
#ifdef TRACE
printf ("sqlca.sqlcode après extraction : %d \n", sqlca.sqlcode);
#endif
exec sql open curseur_liste_poste_parcours_TOTO for readonly;
#ifdef TRACE
printf ("sqlca.sqlcode après ouverture liste : %d \n", sqlca.sqlcode);
#endif
if (sqlca.sqlcode == FOUND)
{
/* lecture du premier enregistrement */
exec sql fetch curseur_liste_poste_parcours_TOTO into :w_poste_parcours_TOTO ;
#ifdef TRACE
printf ("sqlca.sqlcode apres premier fetch : %d \n", sqlca.sqlcode);
#endif
/*
s'il existe au moins 1 enregistrement
on inTOTOalise le 1er element de la liste
*/
if (sqlca.sqlcode == FOUND) {
sqlcode = FOUND ;
w_liste_poste_parcours_TOTO_premier = (s_LISTE_poste_PARCOURS_TOTO *) malloc(sizeof(s_LISTE_poste_PARCOURS_TOTO)) ;
w_liste_poste_parcours_TOTO_premier->s_poste_parcours_TOTO = w_poste_parcours_TOTO ;
w_liste_poste_parcours_TOTO_premier->suivant = NULL ;
w_liste_poste_parcours_TOTO_courant = w_liste_poste_parcours_TOTO_premier ;
nb=1;
exec sql fetch curseur_liste_poste_parcours_TOTO into :w_poste_parcours_TOTO ;
}
}
/* tant que l'on trouve des enregistrements */
/*
On enchaine les enregistrements dans la liste chainee
*/
while (sqlca.sqlcode == FOUND)
{
nb = nb +1;
w_liste_poste_parcours_TOTO_courant->suivant = (s_LISTE_poste_PARCOURS_TOTO *) malloc(sizeof(s_LISTE_poste_PARCOURS_TOTO)) ;
w_liste_poste_parcours_TOTO_courant = w_liste_poste_parcours_TOTO_courant->suivant ;
w_liste_poste_parcours_TOTO_courant->s_poste_parcours_TOTO = w_poste_parcours_TOTO ;
w_liste_poste_parcours_TOTO_courant->suivant = NULL ;
exec sql fetch curseur_liste_poste_parcours_TOTO into :w_poste_parcours_TOTO ;
}
#ifdef TRACE
printf ("sqlca.sqlcode apres tous les fetch : %d \n", sqlca.sqlcode);
#endif
if ( sqlca.sqlcode < FOUND )
sqlcode = sqlca.sqlcode ;
if (( sqlca.sqlcode == FOUND ) || ( sqlca.sqlcode == NOT_FOUND ))
exec sql close curseur_liste_poste_parcours_TOTO ;
/* on fait pointer la liste passée en paramètre sur la tête de la liste */
/* qui vient d'être créée */
*r_liste_poste_parcours_TOTO = w_liste_poste_parcours_TOTO_premier ;
#ifdef TRACE
printf ("nombre enregistrement : %d \n ", nb);
SORTIE_FONCTION;
#endif
return(sqlcode);
} |
Partager