1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
// Remove large objects given on the command line from the default database
#include <iostream>
#include "pqxx/pqxx"
using namespace PGSTD;
using namespace pqxx;
namespace
{
class RemoveLO : public transactor<>
{
oid m_O;
public:
explicit RemoveLO(oid O) : m_O(O) {}
void operator()(argument_type &T)
{
largeobject L(m_O);
L.remove(T);
}
};
}
int main(int, char *argv[])
{
lazyconnection C;
bool Failures = false;
try
{
for (int i=1; argv[i]; ++i)
{
oid O;
from_string(argv[i], O);
try
{
C.perform(RemoveLO(O));
}
catch (const exception &e)
{
cerr << e.what() << endl;
Failures = true;
}
}
}
catch (const exception &e)
{
cerr << e.what() << endl;
return 2;
}
return Failures;
}
|