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