small sample tidy up

This commit is contained in:
Aleksandar Fabijanic
2007-09-24 01:37:31 +00:00
parent 228d48ad14
commit 8506aad3ae
2 changed files with 13 additions and 18 deletions

View File

@@ -15,9 +15,6 @@
// prior written permission from Applied Informatics.
//
#include "Poco/SharedPtr.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/SQLite/Connector.h"
#include <vector>
@@ -62,7 +59,7 @@ int main(int argc, char** argv)
use(person.name),
use(person.address),
use(person.age);
insert.execute();
person.name = "Lisa Simpson";
@@ -84,7 +81,7 @@ int main(int argc, char** argv)
select.execute();
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
}
// another query - store the result in a container
std::vector<std::string> names;
session << "SELECT Name FROM Person",
@@ -95,6 +92,7 @@ int main(int argc, char** argv)
{
std::cout << *it << std::endl;
}
return 0;
}

View File

@@ -65,19 +65,16 @@ int main(int argc, char** argv)
// print all column names
for (std::size_t col = 0; col < cols; ++col)
{
std::cout << rs.columnName(col) << std::endl;
}
// iterate over all rows and columns
bool more = rs.moveFirst();
while (more)
{
for (std::size_t col = 0; col < cols; ++col)
{
std::cout << rs[col].convert<std::string>() << " ";
}
std::cout << std::endl;
more = rs.moveNext();
std::cout << rs.columnName(col) << "\t\t";
}
std::cout << std::endl;
std::cout << "-----------------------------------" << std::endl;
// iterate over all rows and print the data
RecordSet::Iterator it = rs.begin();
RecordSet::Iterator end = rs.end();
for (; it != end; ++it) std::cout << *it;
return 0;
}