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