summaryrefslogtreecommitdiff
path: root/project2/sqlMergeTask.h
diff options
context:
space:
mode:
Diffstat (limited to 'project2/sqlMergeTask.h')
-rw-r--r--project2/sqlMergeTask.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/project2/sqlMergeTask.h b/project2/sqlMergeTask.h
new file mode 100644
index 0000000..be5f6fa
--- /dev/null
+++ b/project2/sqlMergeTask.h
@@ -0,0 +1,119 @@
+#ifndef SQLMERGETASK_H
+#define SQLMERGETASK_H
+
+#include <connection.h>
+#include <modifycommand.h>
+#include <selectcommand.h>
+#include <buffer.h>
+#include "tablepatch.h"
+#include "task.h"
+#include "iterate.h"
+#include <string>
+#include <set>
+#include <map>
+#include <list>
+
+class _SqlMergeTask : public _Task {
+ public:
+ typedef std::string Table;
+ typedef std::string Column;
+
+ typedef std::set<Column> Columns;
+ typedef Columns Keys;
+
+ _SqlMergeTask(const xmlpp::Element * p);
+ virtual ~_SqlMergeTask();
+
+ void execute() const;
+ Columns cols;
+ Keys keys;
+ Keys indexes;
+ const std::string updateWhere;
+ const std::string patchOrder;
+ bool earlyKeys;
+
+ private:
+ virtual void copyToTempTable() const;
+ void createTempTable() const;
+ void dropTempTable() const;
+ void createTempKey() const;
+
+ mutable bool tempTableCreated;
+ Iterates sources;
+ std::list<std::string> sqls;
+ protected:
+ ModifyCommand * insertCommand() const;
+
+ public:
+ mutable ODBC::Connection * destdb;
+ const std::string dataSource;
+ const Table dtable;
+ const Table dtablet;
+
+ static unsigned int defaultVerbosity;
+ static bool defaultUseTempTable;
+};
+
+/*
+class CopyBasedDbConversion : public DbConversion {
+ public:
+ CopyBasedDbConversion(const Connection & dest, const std::string dt);
+ virtual ~CopyBasedDbConversion();
+ private:
+ void copyToTempTable() const;
+ virtual SelectCommand * selectCommand() const = 0;
+};
+class SimpleDbConversion : public CopyBasedDbConversion {
+ public:
+ SimpleDbConversion(const Connection & src, const std::string st, const Connection & dest,
+ const std::string dt);
+ ~SimpleDbConversion();
+ SelectCommand * selectCommand() const;
+ private:
+ const Connection & srcdb;
+ const Table stable;
+ mutable SelectCommand * srcCmd;
+};
+class CustomDbConversion : public CopyBasedDbConversion {
+ public:
+ CustomDbConversion(SelectCommand * srcc, const Connection & dest, const std::string dt);
+ ~CustomDbConversion();
+ private:
+ SelectCommand * selectCommand() const;
+ SelectCommand * srcCmd;
+};
+class EasyFillDbConversion : public DbConversion {
+ public:
+ EasyFillDbConversion(const std::string src, const Connection & db, const std::string dt);
+ ~EasyFillDbConversion();
+
+ private:
+ void copyToTempTable() const;
+ const std::string srcSql;
+};
+class FileFillDbConversion : public DbConversion {
+ public:
+ FileFillDbConversion(const std::string src, const Connection & db, const std::string dt);
+ ~FileFillDbConversion();
+
+ std::list<ODBC::String> post;
+
+ private:
+ void copyToTempTable() const;
+ const std::string srcFile;
+};
+class CustomFillDbConversion : public DbConversion {
+ public:
+ typedef void(*FillFunc)(const CustomFillDbConversion *);
+
+ CustomFillDbConversion(FillFunc fill, const Connection & dest, const std::string dt);
+ ~CustomFillDbConversion();
+
+ private:
+ void copyToTempTable() const;
+ const FillFunc filler;
+};
+*/
+
+#endif
+