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
| #include <sqlenv.h>
#include <sqlutil.h>
#include <stdio.h>
#include <sqlcodes.h>
#include <sqlda.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
EXEC SQL INCLUDE SQLCA ;
EXEC SQL BEGIN DECLARE SECTION;
char dbname[9] = "THEMAT";
char msgbuffer[500];
char gencod[14];
char titre[255];
char chap_id[12];
char req[1000];
char req1[1000];
char date_debut[9];
char date_fin[9];
EXEC SQL END DECLARE SECTION;
int main (int argc, char **argv)
{
char catid[14];
char *chapid;
retourne_chapid_sujet(catid, date_today, &chapid);
printf("%s", chapid);
exit(0);
}
void retourne_chapid_sujet(char *catid, char *date_today, char **chapid)
{
sprintf(req,"SELECT rtrim(chap_id),date_debut as debut,date_fin as fin FROM www_cat_chaps WHERE cat_id = '%s'",catid);
EXEC SQL PREPARE s1 FROM :req;
EXEC SQL DECLARE c1 CURSOR FOR s1;
EXEC SQL OPEN c1;
EXEC SQL FETCH c1 INTO :chap_id,:date_debut,:date_fin;
EXEC SQL CLOSE c1;
if(date_today >= date_debut && date_today <= date_fin)
{
strcpy(*chapid, chap_id);
}
} |
Partager