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_connect();
12 :
13 10 : odbc_command("CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )");
14 10 : odbc_command("CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)");
15 :
16 : /* test hidden column with FOR BROWSE */
17 10 : odbc_reset_statement();
18 :
19 10 : odbc_command("SELECT c, b FROM #tmp1");
20 :
21 10 : CHKNumResultCols(&cnt, "S");
22 :
23 10 : if (cnt != 2) {
24 0 : fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
25 0 : failed = 1;
26 : }
27 10 : odbc_reset_statement();
28 :
29 : /* test hidden column with cursors*/
30 10 : odbc_check_cursor();
31 :
32 8 : CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S");
33 8 : CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S");
34 :
35 8 : CHKPrepare(T("SELECT * FROM #t1"), SQL_NTS, "S");
36 :
37 8 : CHKExecute("S");
38 :
39 8 : CHKNumResultCols(&cnt, "S");
40 :
41 8 : if (cnt != 3) {
42 0 : fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
43 0 : failed = 1;
44 : }
45 :
46 8 : odbc_disconnect();
47 :
48 8 : return failed ? 1: 0;
49 : }
|