1 #undef NDEBUG
2 #include "common.h"
3
4 #include <common/test_assert.h>
5
6 /*
7 Test SQLNumResultCols after SQLFreeStmt
8 This test on Sybase should not raise an error
9 */
10
11 static char software_version[] = "$Id: peter.c 487476 2015-12-17 19:48:39Z ucko $";
12 static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
13
14 int
main(int argc,char * argv[])15 main(int argc, char *argv[])
16 {
17 SQLSMALLINT num_params, cols;
18 SQLLEN count;
19 SQLINTEGER id;
20
21 odbc_use_version3 = 1;
22 odbc_connect();
23
24 odbc_command("create table #tester (id int not null, name varchar(20) not null)");
25 odbc_command("insert into #tester(id, name) values(1, 'abc')");
26 odbc_command("insert into #tester(id, name) values(2, 'duck')");
27
28 CHKPrepare(T("SELECT * FROM #tester WHERE id = ?"), SQL_NTS, "S");
29
30 CHKR(SQLNumParams, (odbc_stmt, &num_params), "S");
31 assert(num_params == 1);
32
33 id = 1;
34 CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, sizeof(id), NULL, "S");
35
36 CHKExecute("S");
37
38 CHKR(SQLFreeStmt, (odbc_stmt, SQL_RESET_PARAMS), "S");
39
40 CHKRowCount(&count, "S");
41
42 CHKNumResultCols(&cols, "S");
43 assert(cols == 2);
44
45 odbc_disconnect();
46 return 0;
47 }
48
49