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