Line data Source code
1 : #include "common.h"
2 :
3 : /* Test for ODBC Rowcount when doing an update with trigger */
4 :
5 : /* avoid indentation using GNU indent */
6 : #define STR(s) s
7 :
8 10 : TEST_MAIN()
9 : {
10 10 : SQLTCHAR *query = T("update test_update set type=type");
11 :
12 10 : odbc_use_version3 = false;
13 10 : odbc_connect();
14 :
15 : /* Cannot use temp table here since they don't allow triggers */
16 10 : odbc_command("IF OBJECT_ID('test_update') IS NOT NULL DROP TABLE test_update");
17 10 : odbc_command("create table test_update (type char(1))");
18 10 : odbc_command("insert test_update values ('A')");
19 10 : odbc_command("insert test_update values ('B')");
20 10 : odbc_command("insert test_update values ('C')");
21 10 : odbc_command("insert test_update values ('D')");
22 10 : odbc_command("insert test_update values ('E')");
23 10 : odbc_command(STR("create trigger test_foo\n")
24 : STR("on test_update for update as\n")
25 : STR("declare @v int\n")
26 : STR("select @v=137"));
27 :
28 10 : puts("SQLPrepare+SQLExecute with trigger");
29 10 : CHKPrepare(query, SQL_NTS, "S");
30 10 : CHKExecute("S");
31 10 : ODBC_CHECK_ROWS(5);
32 :
33 10 : puts("SQLExecDirect with trigger");
34 10 : CHKExecDirect(query, SQL_NTS, "S");
35 10 : ODBC_CHECK_ROWS(5);
36 :
37 10 : CHKExecDirect(T("drop trigger test_foo"), SQL_NTS, "S");
38 :
39 10 : puts("SQLPrepare+SQLExecute without trigger");
40 10 : CHKPrepare(query, SQL_NTS, "S");
41 10 : CHKExecute("S");
42 10 : ODBC_CHECK_ROWS(5);
43 :
44 10 : puts("SQLExecDirect without trigger");
45 10 : CHKExecDirect(query, SQL_NTS, "S");
46 10 : ODBC_CHECK_ROWS(5);
47 :
48 : /* Cleanup */
49 10 : odbc_disconnect();
50 10 : printf("Done.\n");
51 10 : return 0;
52 : }
|