mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-01 11:52:54 +01:00
small sample tidy up
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user