int main(void) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; }
int main(void) { if (sizeof(SQLLEN) != 8) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #tmp1 (i int)"); test_params(); test_rows(); odbc_disconnect(); printf("Done\n"); return 0; }
int main(int argc, char *argv[]) { char tmp[512]; char out[32]; SQLLEN n_len; SQLSMALLINT len; const char * const*p; int n; if (odbc_read_login_info()) exit(1); /* connect string using DSN */ init_connect(); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;DATABASE=%s;ClientCharset=UTF-8;", odbc_server, odbc_user, odbc_password, odbc_database); CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SI"); if (!odbc_driver_is_freetds()) { odbc_disconnect(); printf("Driver is not FreeTDS, exiting\n"); odbc_test_skipped(); return 0; } if (!odbc_db_is_microsoft() || odbc_db_version_int() < 0x08000000u || odbc_tds_version() < 0x701) { odbc_disconnect(); /* protocol till 7.1 does not support telling encoding so we * cannot understand how the string is encoded */ printf("Test for MSSQL only using protocol 7.1\n"); odbc_test_skipped(); return 0; } CHKAllocStmt(&odbc_stmt, "S"); /* create test table */ odbc_command("CREATE TABLE #tmpHebrew (i INT, v VARCHAR(10) COLLATE Hebrew_CI_AI)"); /* insert with INSERT statements */ for (n = 0, p = strings_hex; p[n]; ++n) { sprintf(tmp, "INSERT INTO #tmpHebrew VALUES(%d, CAST(%s AS NVARCHAR(10)))", n+1, p[n]); odbc_command(tmp); } /* test conversions in libTDS */ odbc_command("SELECT v FROM #tmpHebrew"); /* insert with SQLPrepare/SQLBindParameter/SQLExecute */ CHKBindCol(1, SQL_C_CHAR, out, sizeof(out), &n_len, "S"); for (n = 0, p = strings; p[n]; ++n) { CHKFetch("S"); if (n_len != strlen(p[n]) || strcmp(p[n], out) != 0) { fprintf(stderr, "Wrong row %d %s\n", n, out); odbc_disconnect(); return 1; } } odbc_disconnect(); printf("Done.\n"); return 0; }
int main(int argc, char *argv[]) { SQLINTEGER len, out; int i; SQLHSTMT stmt1, stmt2; SQLHSTMT *pcur_stmt = NULL; odbc_use_version3 = 1; odbc_set_conn_attr = my_attrs; odbc_connect(); stmt1 = odbc_stmt; out = 0; len = sizeof(out); CHKGetConnectAttr(1224, (SQLPOINTER) &out, sizeof(out), &len, "S"); /* test we really support MARS on this connection */ /* TODO should out be correct ?? */ printf("Following row can contain an error due to MARS detection (is expected)\n"); if (!out || odbc_command2("BEGIN TRANSACTION", "SNoE") != SQL_ERROR) { printf("MARS not supported for this connection\n"); odbc_disconnect(); odbc_test_skipped(); return 0; } odbc_read_error(); if (!strstr(odbc_err, "MARS")) { printf("Error message invalid \"%s\"\n", odbc_err); return 1; } /* create a test table with some data */ odbc_command("create table #mars1 (n int, v varchar(100))"); for (i = 0; i < 60; ++i) { char cmd[120], buf[80]; memset(buf, 'a' + (i % 26), sizeof(buf)); buf[i * 7 % 73] = 0; sprintf(cmd, "insert into #mars1 values(%d, '%s')", i, buf); odbc_command(cmd); } /* and another to avid locking problems */ odbc_command("create table #mars2 (n int, v varchar(100))"); AutoCommit(SQL_AUTOCOMMIT_OFF); /* try to do a select which return a lot of data (to test server didn't cache everything) */ odbc_command("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n, b.n"); CHKFetch("S"); /* try to do other commands */ CHKAllocStmt(&stmt2, "S"); SET_STMT(stmt2); odbc_command("insert into #mars2 values(1, 'foo')"); SET_STMT(stmt1); CHKFetch("S"); /* reset statements */ odbc_reset_statement(); SET_STMT(stmt2); odbc_reset_statement(); /* now to 2 select with prepare/execute */ CHKPrepare(T("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n, b.n"), SQL_NTS, "S"); SET_STMT(stmt1); CHKPrepare(T("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n desc, b.n"), SQL_NTS, "S"); SET_STMT(stmt2); CHKExecute("S"); SET_STMT(stmt1); CHKExecute("S"); SET_STMT(stmt2); CHKFetch("S"); SET_STMT(stmt1); CHKFetch("S"); SET_STMT(stmt2); CHKFetch("S"); odbc_reset_statement(); SET_STMT(stmt1); CHKFetch("S"); odbc_reset_statement(); EndTransaction(SQL_COMMIT); /* TODO test receiving large data should not take much memory */ odbc_disconnect(); return 0; }