updated Data samples; updated SQlite to 3.5.5

This commit is contained in:
Guenter Obiltschnig 2008-02-03 13:48:59 +00:00
parent be815af919
commit cf60e2a5d8
5 changed files with 87760 additions and 70600 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
//
// Binding.cpp
//
// $Id: //poco/Main/Data/samples/Binding/src/Binding.cpp#1 $
// $Id: //poco/Main/Data/samples/Binding/src/Binding.cpp#2 $
//
// This sample demonstrates the Data library.
//
@ -15,6 +15,7 @@
// prior written permission from Applied Informatics.
//
#include "Poco/Data/Session.h"
#include "Poco/Data/SQLite/Connector.h"
#include <vector>
@ -55,7 +56,7 @@ int main(int argc, char** argv)
};
Statement insert(session);
insert << "INSERT INTO Person VALUES(:name, :address, :age)",
insert << "INSERT INTO Person VALUES(?, ?, ?)",
use(person.name),
use(person.address),
use(person.age);

View File

@ -20,6 +20,7 @@
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/RecordSet.h"
#include "Poco/Data/Column.h"
#include "Poco/Data/SQLite/Connector.h"
#include <iostream>
@ -27,6 +28,14 @@
using namespace Poco::Data;
struct Person
{
std::string name;
std::string address;
int age;
};
int main(int argc, char** argv)
{
// register SQLite connector
@ -42,20 +51,33 @@ int main(int argc, char** argv)
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
// insert some rows
session << "INSERT INTO Person VALUES('Homer Simpson', 'Springfield', 42)", now;
session << "INSERT INTO Person VALUES('Marge Simpson', 'Springfield', 38)", now;
session << "INSERT INTO Person VALUES('Bart Simpson', 'Springfield', 12)", now;
session << "INSERT INTO Person VALUES('Lisa Simpson', 'Springfield', 10)", now;
// create a recordset and print the column names and data
RecordSet rs(session, "SELECT * FROM Person");
std::cout << rs;
// a simple query
Statement select(session);
select << "SELECT * FROM Person";
select.execute();
// print just two middle rows
std::cout << std::endl << "Middle rows :" << std::endl;
rs.copyValues(std::cout, 1, 2);
std::cout << "---" << std::endl << "Thats all, folks!" << std::endl;
// create a RecordSet
RecordSet rs(select);
std::size_t cols = rs.columnCount();
// 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();
}
return 0;
}

View File

@ -1,7 +1,7 @@
//
// Binding.cpp
//
// $Id: //poco/Main/Data/samples/TypeHandler/src/TypeHandler.cpp#2 $
// $Id: //poco/Main/Data/samples/TypeHandler/src/TypeHandler.cpp#3 $
//
// This sample demonstrates the Data library.
//
@ -100,7 +100,7 @@ int main(int argc, char** argv)
};
Statement insert(session);
insert << "INSERT INTO Person VALUES(:name, :address, :age)",
insert << "INSERT INTO Person VALUES(?, ?, ?)",
use(person);
insert.execute();