Bonjour,

je cherche depuis hier la solution à mon problème. Je fais du C depuis deux jours donc le code doit être loin d'être propre.

Le souci provient de mon SQLExecute qui se produit pas une fois mais deux fois (dont la deuxième avec des paramètres à vides)

je vous copie le code pour voir si vous avez une idée pour résoudre ce souci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
110
111
long TIM_SAI_RECUP_PART_ID_CPTE( long SAI_HD_SESSION,
                                 char SAI_CD_ELTCONT[36],
                                 struct PARTCPT **HD_SEG_PART)
{
 
 
char ReqSQL[4096] ="";
 
// Element de contrat 
char NOCMPT[12];
int iResult;
 
int izLngParam1 = 4012;
int izLngParam2 = 2;
int izLngParam3 = 4000;
char szParam1[4012];
char szParam2[2];
char szParam3[4000];
int izRetParam1 = SQL_NTS;
int izRetParam2 = SQL_NTS;
int izRetParam3 = SQL_NTS;
char szProg[50];
 
 
 
	 if (henv == NULL)
	{
		SQLAllocEnv(&henv);
		SQLAllocConnect(henv,&hdbc);
		strcpy(chr_ds_name,(const unsigned char *)szOdbcName);
		retcode = SQLConnect(hdbc,chr_ds_name,SQL_NTS,(SQLCHAR *) szUName,SQL_NTS,(SQLCHAR *) szPSName,SQL_NTS);
		SQLSetConnectOption(hdbc,SQL_CURSOR_TYPE,SQL_CURSOR_DYNAMIC);
		iResult= SQLAllocStmt(hdbc,&hstmt);
	}
 
 
	memset(NOCMPT,'\0',sizeof(NOCMPT));
	memset(szParam1,'\0',sizeof(szParam1));
	memset(szParam2,'\0',sizeof(szParam2));
	memset(szParam3,'\0',sizeof(szParam3));
	memset(szProg,'\0',sizeof(szProg));
	memset((*HD_SEG_PART),'\0',sizeof((*HD_SEG_PART)));
 
 
    // Allocation de la connection
    SQLAllocHandle(SQL_HANDLE_STMT, &hdbc, &hstmt);
 
 
	strcpy(szProg, "CALL ");
	strncat(szProg, szProcedCatalog,18);
	strcat(szProg,"(?,?,?)");
 
		// Affectation des paramètres
 
 
    strcpy(szParam1, "EIBMPB003 ");
    strcpy(szParam2, "00");
	memcpy(NOCMPT,&SAI_CD_ELTCONT[0],11);
    memcpy(szParam3,NOCMPT,35);
 
 
	// Prepare the stored procedure statement
 
	if(SQLPrepare(hstmt,(SQLCHAR *) szProg, SQL_NTS)!= SQL_SUCCESS) {
		return C_API_PB_INDETERMINE;
		}	
 
 
	// Construction des paramètres
	// Paramètre 1 - Nom de la procédure à lancer)
 
	if(SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_CHAR, izLngParam1, 0, szParam1, 0, &izRetParam1) != SQL_SUCCESS) {
		return C_API_PB_INDETERMINE;
		}
 
 
	// Paramètre 2 - Code Retour d'execution de la procédure)
 
     if(SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_CHAR, izLngParam2, 0, szParam2, 0, &izRetParam2) != SQL_SUCCESS) {
		return C_API_PB_INDETERMINE;
		}
 
 
	// Paramètre 3 - Zone d'échange programme
 
	if(SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_CHAR, izLngParam3, 0, szParam3, 0, &izRetParam3) != SQL_SUCCESS) {
		return C_API_PB_INDETERMINE;
		} 
 
 
	// Exécution de la procédure
 
    if (SQLExecute(hstmt)!= SQL_SUCCESS) {
		return C_API_PB_INDETERMINE;
    }
 
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
 
	SQLCloseCursor(hstmt);	
 
 
	if(strcmp(szParam2, "00"))
	{
		return C_API_PB_INDETERMINE;
    }
 
    memmove(*HD_SEG_PART, szParam3+35, sizeof((*HD_SEG_PART)));	
 
	return C_API_OK;
 
}

Je vous remercie d'avance