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