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