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