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