mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
MySQL DateTime support, samples Linux compile
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "Poco/String.h"
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Tuple.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/Any.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/Data/LOB.h"
|
||||
@@ -58,6 +59,7 @@ using Poco::Data::MySQL::ConnectionException;
|
||||
using Poco::Data::MySQL::StatementException;
|
||||
using Poco::format;
|
||||
using Poco::Tuple;
|
||||
using Poco::DateTime;
|
||||
using Poco::Any;
|
||||
using Poco::AnyCast;
|
||||
using Poco::NotFoundException;
|
||||
@@ -1295,6 +1297,35 @@ void SQLExecutor::blob(int bigSize)
|
||||
assert (res == big);
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::dateTime()
|
||||
{
|
||||
std::string funct = "dateTime()";
|
||||
std::string lastName("Bart");
|
||||
std::string firstName("Simpson");
|
||||
std::string address("Springfield");
|
||||
DateTime birthday(1980, 4, 1, 5, 45, 12);
|
||||
|
||||
int count = 0;
|
||||
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assert (count == 1);
|
||||
|
||||
DateTime bd;
|
||||
assert (bd != birthday);
|
||||
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
|
||||
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
|
||||
assert (bd == birthday);
|
||||
|
||||
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::blobStmt()
|
||||
{
|
||||
std::string funct = "blobStmt()";
|
||||
@@ -1320,6 +1351,7 @@ void SQLExecutor::blobStmt()
|
||||
poco_assert (res == blob);
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::tuples()
|
||||
{
|
||||
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
|
||||
@@ -1338,6 +1370,7 @@ void SQLExecutor::tuples()
|
||||
assert (ret == t);
|
||||
}
|
||||
|
||||
|
||||
void SQLExecutor::tupleVector()
|
||||
{
|
||||
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
|
||||
|
||||
Reference in New Issue
Block a user