Line data Source code
1 : #include "common.h"
2 :
3 : /* test error on prepared statement, from Nathaniel Talbott test */
4 :
5 : int
6 8 : main(void)
7 : {
8 8 : SQLLEN cbInString = SQL_NTS;
9 : char buf[256];
10 : SQLTCHAR msg[256];
11 : SQLTCHAR sqlstate[6];
12 :
13 8 : odbc_connect();
14 :
15 8 : odbc_command("CREATE TABLE #urls ( recdate DATETIME ) ");
16 :
17 : /* test implicit conversion error */
18 8 : CHKExecDirect(T("INSERT INTO #urls ( recdate ) VALUES ( '2003-10-1 10:11:1 0' )"), SQL_NTS, "E");
19 :
20 : /* test prepared implicit conversion error */
21 8 : CHKPrepare(T("INSERT INTO #urls ( recdate ) VALUES ( ? )"), SQL_NTS, "SI");
22 :
23 8 : strcpy(buf, "2003-10-1 10:11:1 0");
24 8 : CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 128, 0, buf, sizeof(buf), &cbInString, "SI");
25 :
26 8 : CHKExecute("E");
27 :
28 8 : CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, TDS_VECTOR_SIZE(buf), NULL, "SI");
29 8 : printf("err=%s\n", C(msg));
30 :
31 : /* assure initial state */
32 8 : odbc_reset_statement();
33 :
34 : /* try to prepare and execute a statement with error (from DBD::ODBC test) */
35 8 : if (CHKPrepare(T("SELECT XXNOTCOLUMN FROM sysobjects"), SQL_NTS, "SE") == SQL_SUCCESS)
36 6 : CHKExecute("E");
37 :
38 8 : CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, TDS_VECTOR_SIZE(buf), NULL, "SI");
39 8 : printf("err=%s\n", C(msg));
40 :
41 :
42 8 : odbc_disconnect();
43 :
44 8 : printf("Done.\n");
45 8 : ODBC_FREE();
46 : return 0;
47 : }
|