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 8 : main(void)
11 : {
12 : SQLSMALLINT num_params, cols;
13 : SQLLEN count;
14 : SQLINTEGER id;
15 :
16 8 : odbc_use_version3 = 1;
17 8 : odbc_connect();
18 :
19 8 : odbc_command("create table #tester (id int not null, name varchar(20) not null)");
20 8 : odbc_command("insert into #tester(id, name) values(1, 'abc')");
21 8 : odbc_command("insert into #tester(id, name) values(2, 'duck')");
22 :
23 8 : CHKPrepare(T("SELECT * FROM #tester WHERE id = ?"), SQL_NTS, "S");
24 :
25 8 : CHKNumParams(&num_params, "S");
26 8 : assert(num_params == 1);
27 :
28 8 : id = 1;
29 8 : CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, sizeof(id), NULL, "S");
30 :
31 8 : CHKExecute("S");
32 :
33 8 : CHKFreeStmt(SQL_RESET_PARAMS, "S");
34 :
35 8 : CHKRowCount(&count, "S");
36 :
37 8 : CHKNumResultCols(&cols, "S");
38 8 : assert(cols == 2);
39 :
40 8 : odbc_disconnect();
41 : return 0;
42 : }
43 :
|