3939#include " Poco/Any.h"
4040#include " Poco/Exception.h"
4141#include " Poco/Data/LOB.h"
42+ #include " Poco/Data/Date.h"
43+ #include " Poco/Data/Time.h"
4244#include " Poco/Data/StatementImpl.h"
4345#include " Poco/Data/RecordSet.h"
4446#include " Poco/Data/Transaction.h"
@@ -1253,58 +1255,69 @@ void SQLExecutor::emptyDB()
12531255}
12541256
12551257
1256- void SQLExecutor::blob ( int bigSize )
1258+ void SQLExecutor::dateTime ( )
12571259{
1258- std::string funct = " blob ()" ;
1259- std::string lastName (" lastname " );
1260- std::string firstName (" firstname " );
1261- std::string address (" Address " );
1262-
1263- Poco::Data::CLOB img ( " 0123456789 " , 10 );
1260+ std::string funct = " dateTime ()" ;
1261+ std::string lastName (" Bart " );
1262+ std::string firstName (" Simpson " );
1263+ std::string address (" Springfield " );
1264+ DateTime birthday ( 1980 , 4 , 1 , 5 , 45 , 12 );
1265+
12641266 int count = 0 ;
1265- try { *_pSession << " INSERT INTO Person VALUES (?,?,?,?)" , use (lastName), use (firstName), use (address), use (img ), now; }
1267+ try { *_pSession << " INSERT INTO Person VALUES (?,?,?,?)" , use (lastName), use (firstName), use (address), use (birthday ), now; }
12661268 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12671269 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
12681270 try { *_pSession << " SELECT COUNT(*) FROM Person" , into (count), now; }
12691271 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12701272 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
12711273 assert (count == 1 );
1272-
1273- Poco::Data::CLOB res ;
1274- assert (res. size () == 0 );
1275- try { *_pSession << " SELECT Image FROM Person" , into (res ), now; }
1274+
1275+ DateTime bd ;
1276+ assert (bd != birthday );
1277+ try { *_pSession << " SELECT Birthday FROM Person" , into (bd ), now; }
12761278 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12771279 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1278- assert (res == img);
1279-
1280- Poco::Data::CLOB big;
1281- std::vector<char > v (bigSize, ' x' );
1282- big.assignRaw (&v[0 ], (std::size_t ) v.size ());
1280+ assert (bd == birthday);
1281+
1282+ std::cout << std::endl << RecordSet (*_pSession, " SELECT * FROM Person" );
1283+ }
12831284
1284- assert (big.size () == (std::size_t ) bigSize);
12851285
1286- try { *_pSession << " DELETE FROM Person" , now; }
1286+ void SQLExecutor::date ()
1287+ {
1288+ std::string funct = " date()" ;
1289+ std::string lastName (" Bart" );
1290+ std::string firstName (" Simpson" );
1291+ std::string address (" Springfield" );
1292+ Date birthday (1980 , 4 , 1 );
1293+
1294+ int count = 0 ;
1295+ try { *_pSession << " INSERT INTO Person VALUES (?,?,?,?)" , use (lastName), use (firstName), use (address), use (birthday), now; }
12871296 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12881297 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1289-
1290- try { *_pSession << " INSERT INTO Person VALUES(?,?,?,?)" , use (lastName), use (firstName), use (address), use (big), now; }
1298+ try { *_pSession << " SELECT COUNT(*) FROM Person" , into (count), now; }
12911299 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12921300 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1293-
1294- try { *_pSession << " SELECT Image FROM Person" , into (res), now; }
1301+ assert (count == 1 );
1302+
1303+ Date bd;
1304+ assert (bd != birthday);
1305+ try { *_pSession << " SELECT Birthday FROM Person" , into (bd), now; }
12951306 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
12961307 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1297- assert (res == big);
1308+ assert (bd == birthday);
1309+
1310+ std::cout << std::endl << RecordSet (*_pSession, " SELECT * FROM Person" );
12981311}
12991312
13001313
1301- void SQLExecutor::dateTime ()
1314+ void SQLExecutor::time ()
13021315{
1303- std::string funct = " dateTime ()" ;
1316+ std::string funct = " date ()" ;
13041317 std::string lastName (" Bart" );
13051318 std::string firstName (" Simpson" );
13061319 std::string address (" Springfield" );
1307- DateTime birthday (1980 , 4 , 1 , 5 , 45 , 12 );
1320+ Time birthday (1 , 2 , 3 );
13081321
13091322 int count = 0 ;
13101323 try { *_pSession << " INSERT INTO Person VALUES (?,?,?,?)" , use (lastName), use (firstName), use (address), use (birthday), now; }
@@ -1315,7 +1328,7 @@ void SQLExecutor::dateTime()
13151328 catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
13161329 assert (count == 1 );
13171330
1318- DateTime bd;
1331+ Time bd;
13191332 assert (bd != birthday);
13201333 try { *_pSession << " SELECT Birthday FROM Person" , into (bd), now; }
13211334 catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
@@ -1326,6 +1339,51 @@ void SQLExecutor::dateTime()
13261339}
13271340
13281341
1342+ void SQLExecutor::blob (int bigSize)
1343+ {
1344+ std::string funct = " blob()" ;
1345+ std::string lastName (" lastname" );
1346+ std::string firstName (" firstname" );
1347+ std::string address (" Address" );
1348+
1349+ Poco::Data::CLOB img (" 0123456789" , 10 );
1350+ int count = 0 ;
1351+ try { *_pSession << " INSERT INTO Person VALUES (?,?,?,?)" , use (lastName), use (firstName), use (address), use (img), now; }
1352+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1353+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1354+ try { *_pSession << " SELECT COUNT(*) FROM Person" , into (count), now; }
1355+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1356+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1357+ assert (count == 1 );
1358+
1359+ Poco::Data::CLOB res;
1360+ assert (res.size () == 0 );
1361+ try { *_pSession << " SELECT Image FROM Person" , into (res), now; }
1362+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1363+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1364+ assert (res == img);
1365+
1366+ Poco::Data::CLOB big;
1367+ std::vector<char > v (bigSize, ' x' );
1368+ big.assignRaw (&v[0 ], (std::size_t ) v.size ());
1369+
1370+ assert (big.size () == (std::size_t ) bigSize);
1371+
1372+ try { *_pSession << " DELETE FROM Person" , now; }
1373+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1374+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1375+
1376+ try { *_pSession << " INSERT INTO Person VALUES(?,?,?,?)" , use (lastName), use (firstName), use (address), use (big), now; }
1377+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1378+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1379+
1380+ try { *_pSession << " SELECT Image FROM Person" , into (res), now; }
1381+ catch (ConnectionException& ce){ std::cout << ce.displayText () << std::endl; fail (funct); }
1382+ catch (StatementException& se){ std::cout << se.displayText () << std::endl; fail (funct); }
1383+ assert (res == big);
1384+ }
1385+
1386+
13291387void SQLExecutor::blobStmt ()
13301388{
13311389 std::string funct = " blobStmt()" ;
0 commit comments