[Libpqxx-general] tablereader /tablewriter
Roshni Mani
m.roshni at teles.com
Mon Sep 15 06:27:04 UTC 2008
hi,
i had written a simple c++ program given below for writing to a table from a table.it dint work ,but there are no errors .i think this is either logical / syntax error from my part .i'm new to libpqxx .can somebody tell me what is the problem with this program?
#include<iostream>
#include<pqxx/pqxx>
using namespace std;
using namespace pqxx;
int main()
{
try
{
const string connstring("host=127.0.0.1 dbname=template1 user=pgsql password=");
string m_Table("employee_copy");
connection conn(connstring);
transaction<serializable> T(conn);
T.exec(("CREATE TABLE " + m_Table + "(NAME VARCHAR(20),DESIGNATION VARCHAR(15),EMPLOYEE_NUMBER INTEGER)").c_str());
tablereader read_orig(T,"employee");
read_orig.complete();
tablewriter copy_dest(T,m_Table);
copy_dest<<read_orig;
copy_dest.complete();
T.commit();
}
catch(const sql_error &e)
{
cerr<<"exception:"<<e.what()<<endl;
}
catch(const exception &e)
{
cerr<<"exception:"<<e.what()<<endl;
}
}
void on_commit()
{
cout<<"\n\ntable copied";
}
Thanks and regards,
Roshni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pgfoundry.org/pipermail/libpqxx-general/attachments/20080915/2758962b/attachment.html
More information about the Libpqxx-general
mailing list