29 sql <<
"CREATE TABLE SOCI_TEST(ID INTEGER, VAL SMALLINT, C CHAR, STR VARCHAR(20), SH SMALLINT, UL NUMERIC(20), D DOUBLE, " 30 "TM TIMESTAMP(9), I1 INTEGER, I2 INTEGER, I3 INTEGER, NAME VARCHAR(20))";
39 sql <<
"CREATE TABLE SOCI_TEST(NUM_FLOAT DOUBLE, NUM_INT INTEGER, NAME VARCHAR(20), SOMETIME TIMESTAMP, CHR CHAR)";
48 sql <<
"CREATE TABLE SOCI_TEST(NAME VARCHAR(100) NOT NULL, PHONE VARCHAR(15))";
57 sql <<
"CREATE TABLE SOCI_TEST(VAL INTEGER)";
94 return "\'" + datdt_string +
"\'";
103 sql <<
"CREATE TABLE SOCI_TEST (VAL BIGINT)";
109 const int num_recs = 100;
116 "INSERT INTO SOCI_TEST (VAL) VALUES (:val)",
use(n));
117 for (
int i = 0; i < num_recs; i++)
119 n = 1000000000LL + i;
126 "SELECT VAL FROM SOCI_TEST ORDER BY VAL",
into(n2));
128 for (
int i = 0; i < num_recs; i++)
131 assert(n2 == 1000000000LL + i);
135 std::cout <<
"test odbc_db2_long_long passed" << std::endl;
140 const int num_recs = 100;
145 unsigned long long n;
147 "INSERT INTO SOCI_TEST (VAL) VALUES (:val)",
use(n));
148 for (
int i = 0; i < num_recs; i++)
150 n = 1000000000LL + i;
155 unsigned long long n2;
157 "SELECT VAL FROM SOCI_TEST ORDER BY VAL",
into(n2));
159 for (
int i = 0; i < num_recs; i++)
162 assert(n2 == 1000000000LL + i);
166 std::cout <<
"test odbc_db2_unsigned_long_long passed" << std::endl;
171 const std::size_t num_recs = 100;
176 std::vector<long long> v(num_recs);
177 for (std::size_t i = 0; i < num_recs; i++)
179 v[i] = 1000000000LL + i;
182 sql <<
"INSERT INTO SOCI_TEST (VAL) VALUES (:bi)",
use(v);
185 std::size_t recs = 0;
187 std::vector<long long> v(num_recs / 2 + 1);
189 "SELECT VAL FROM SOCI_TEST ORDER BY VAL",
into(v));
198 const std::size_t vsize = v.size();
199 for (std::size_t i = 0; i < vsize; i++)
201 assert(v[i] == 1000000000LL +
202 static_cast<long long>(recs));
206 assert(recs == num_recs);
209 std::cout <<
"test odbc_db2_long_long_vector passed" << std::endl;
214 const std::size_t num_recs = 100;
219 std::vector<unsigned long long> v(num_recs);
220 for (std::size_t i = 0; i < num_recs; i++)
222 v[i] = 1000000000LL + i;
225 sql <<
"INSERT INTO SOCI_TEST (VAL) VALUES (:bi)",
use(v);
228 std::size_t recs = 0;
230 std::vector<unsigned long long> v(num_recs / 2 + 1);
232 "SELECT VAL FROM SOCI_TEST ORDER BY VAL",
into(v));
241 const std::size_t vsize = v.size();
242 for (std::size_t i = 0; i < vsize; i++)
244 assert(v[i] == 1000000000LL +
245 static_cast<unsigned long long>(recs));
249 assert(recs == num_recs);
252 std::cout <<
"test odbc_db2_unsigned_long_long_vector passed" << std::endl;
255 int main(
int argc,
char** argv)
262 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
263 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
272 std::cerr << std::endl <<
273 "usage: test-odbc-db2 \"DSN=<db>;Uid=<user>;Pwd=<password>\"" <<
274 std::endl << std::endl;
279 std::cout <<
"\nSOCI ODBC with DB2 Tests:\n\n";
285 std::cout <<
"\nSOCI DB2 Specific Tests:\n\n";
291 std::cout <<
"\nOK, all tests passed.\n\n";
298 <<
"SOCI Message: " << e.what() << std::endl
301 catch (std::exception
const & e)
303 std::cout <<
"STD::EXECEPTION " << e.what() <<
'\n';
SQLCHAR const * odbc_error_message() const
details::into_container< T, details::no_indicator > into(T &t)
test_context(backend_factory const &backEnd, std::string const &connectString)
void test_odbc_db2_unsigned_long_long()
table_creator_base * table_creator_2(session &s) const
void run(bool dbSupportsTransactions=true)
void test_odbc_db2_unsigned_long_long_vector()
table_creator_one(session &sql)
table_creator_base * table_creator_4(session &s) const
backend_factory const & backEnd
void test_odbc_db2_long_long()
SQLINTEGER native_error_code() const
std::string connectString
table_creator_base * table_creator_1(session &s) const
void test_odbc_db2_long_long_vector()
table_creator_base * table_creator_3(session &s) const
table_creator_for_get_affected_rows(session &sql)
SQLCHAR const * odbc_error_code() const
std::string to_date_time(std::string const &datdt_string) const
int main(int argc, char **argv)
table_creator_bigint(session &sql)
table_creator_two(session &sql)
SOCI_ODBC_DECL backend_factory const * factory_odbc()
details::prepare_type prepare
table_creator_three(session &sql)
details::use_container< T, details::no_indicator > use(T &t, const std::string &name=std::string())
bool execute(bool withDataExchange=false)