The following code creates a table named "test" in POCO:
#include "Poco/Data/Session.h"
#include "Poco/Data/SQLite/Connector.h"
#include <string>
using namespace Poco::Data::Keywords;
using Poco::Data::Session;
int main(int argc, char** argv)
{
Poco::Data::SQLite::Connector::registerConnector();
Session session("SQLite", "test.db");
session << "CREATE TABLE test (id INTEGER)", now;
return 0;
}
I want to write a function which creates tables named according to the given arguments. I would have thought to use
int main(int argc, char** argv)
{
Poco::Data::SQLite::Connector::registerConnector();
Session session("SQLite", "test.db");
std::string name = "test";
session << "CREATE TABLE ? (id INTEGER)", bind(name), now;
return 0;
}
Using the wildcard character and replacing it with the given name. As I understand it, I shouldn't even need bind (which copies the given value) and use should be sufficient since the statement is terminated with now, but no matter.
Regardless of which keyword I use (use, bind, useRef), the program throws an "SQL error or missing database" error.
I've also tried creating a Statement and have it create the table, but no change.
Am I doing something wrong? Is wildcard substitution not allowed with this call? Do I have to modify the call manually?
Should it be relevant, as can be inferred from my #includes, I'm using SQLite.