1 /* Testing result column numbers having hidden columns */
2 /* Test from Sebastien Flaesch */
3 
4 #include "common.h"
5 
6 int
main(int argc,char ** argv)7 main(int argc, char **argv)
8 {
9 	SQLSMALLINT cnt = 0;
10 	int failed = 0;
11 
12 	odbc_use_version3 = 1;
13 	odbc_connect();
14 
15 	odbc_command("CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )");
16 	odbc_command("CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)");
17 
18 	/* test hidden column with FOR BROWSE */
19 	odbc_reset_statement();
20 
21 	odbc_command("SELECT c, b FROM #tmp1");
22 
23 	CHKNumResultCols(&cnt, "S");
24 
25 	if (cnt != 2) {
26 		fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
27 		failed = 1;
28 	}
29 	odbc_reset_statement();
30 
31 	/* test hidden column with cursors*/
32 	odbc_check_cursor();
33 
34 	CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S");
35 	CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S");
36 
37 	CHKPrepare(T("SELECT * FROM #t1"), SQL_NTS, "S");
38 
39 	CHKExecute("S");
40 
41 	CHKNumResultCols(&cnt, "S");
42 
43 	if (cnt != 3) {
44 		fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
45 		failed = 1;
46 	}
47 
48 	odbc_disconnect();
49 
50 	return failed ? 1: 0;
51 }
52