Line data Source code
1 : #include "common.h"
2 :
3 10 : TEST_MAIN()
4 : {
5 10 : HSTMT old_odbc_stmt = SQL_NULL_HSTMT;
6 :
7 10 : odbc_connect();
8 :
9 10 : odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata");
10 :
11 10 : odbc_command("create table #odbctestdata (i int)");
12 10 : odbc_command("insert #odbctestdata values (123)");
13 :
14 : /*
15 : * now we allocate another statement, select, get all results
16 : * then make another query with first select and drop this statement
17 : * result should not disappear (required for DBD::ODBC)
18 : */
19 10 : SWAP_STMT(old_odbc_stmt);
20 10 : CHKAllocStmt(&odbc_stmt, "S");
21 :
22 10 : odbc_command("select * from #odbctestdata where 0=1");
23 :
24 10 : CHKFetch("No");
25 :
26 10 : CHKCloseCursor("SI");
27 :
28 10 : SWAP_STMT(old_odbc_stmt);
29 10 : odbc_command("select * from #odbctestdata");
30 10 : SWAP_STMT(old_odbc_stmt);
31 :
32 : /* drop first statement .. data should not disappear */
33 10 : CHKFreeStmt(SQL_DROP, "S");
34 10 : odbc_stmt = SQL_NULL_HSTMT;
35 10 : SWAP_STMT(old_odbc_stmt);
36 :
37 10 : CHKFetch("SI");
38 :
39 10 : CHKFetch("No");
40 :
41 10 : CHKCloseCursor("SI");
42 :
43 10 : odbc_command("drop table #odbctestdata");
44 :
45 10 : odbc_disconnect();
46 :
47 10 : printf("Done.\n");
48 10 : return 0;
49 : }
|