Line data Source code
1 : #include "common.h"
2 : #include <assert.h>
3 :
4 : /*
5 : Test for a bug executing after a not successfully execute
6 : */
7 :
8 10 : TEST_MAIN()
9 : {
10 : SQLSMALLINT num_params;
11 10 : SQLLEN sql_nts = SQL_NTS;
12 : char string[20];
13 : SQLINTEGER id;
14 :
15 10 : odbc_connect();
16 :
17 10 : odbc_command("create table #tester (id int not null primary key, name varchar(20) not null)");
18 10 : odbc_command("insert into #tester(id, name) values(1, 'abc')");
19 10 : odbc_command("insert into #tester(id, name) values(2, 'duck')");
20 :
21 10 : odbc_reset_statement();
22 :
23 10 : CHKPrepare(T("insert into #tester(id, name) values(?,?)"), SQL_NTS, "S");
24 :
25 10 : CHKNumParams(&num_params, "S");
26 10 : assert(num_params == 2);
27 :
28 : /* now this is going to fail as id is duplicated, causing statement to not be prepared */
29 10 : id = 1;
30 10 : CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, 0, &sql_nts, "S");
31 10 : strcpy(string, "test");
32 10 : CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "S");
33 10 : CHKExecute("E");
34 :
35 : /* this should success */
36 10 : id = 4;
37 10 : strcpy(string, "test2");
38 10 : CHKExecute("S");
39 :
40 10 : odbc_disconnect();
41 10 : return 0;
42 : }
43 :
|