00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef DBAGENERICFETCHER_H
00010 #define DBAGENERICFETCHER_H
00011
00012 #include "dba/sqlidfetcher.h"
00013 #include "dba/sqlarchive.h"
00014 #include <memory>
00015
00016 namespace dba {
00017
00023 class dbaDLLEXPORT GenericFetcher : public dba::SQLIdFetcher {
00024 public:
00025 GenericFetcher();
00026 virtual int getNextId(dba::DbConnection& pConn, const char*) {
00027 std::auto_ptr<dba::DbResult> res(pConn.sendQuery("SELECT id FROM debea_object_count"));
00028 if (!res->fetchRow())
00029 throw dba::DataException("Unable to allocate next object id");
00030 int id = res->getInt(0);
00031 res.reset();
00032 pConn.sendUpdate("UPDATE debea_object_count SET id = id + 1");
00033 return id;
00034 };
00035 virtual ~GenericFetcher();
00036 };
00037
00038 };
00039
00040
00041 #endif