summaryrefslogtreecommitdiff
path: root/odb/relational/oracle/schema.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/relational/oracle/schema.cxx')
-rw-r--r--odb/relational/oracle/schema.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx
index 7b8a622..acc512f 100644
--- a/odb/relational/oracle/schema.cxx
+++ b/odb/relational/oracle/schema.cxx
@@ -3,11 +3,15 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v3; see accompanying LICENSE file
+#include <string>
+
#include <odb/relational/schema.hxx>
#include <odb/relational/oracle/common.hxx>
#include <odb/relational/oracle/context.hxx>
+using namespace std;
+
namespace relational
{
namespace oracle
@@ -16,6 +20,48 @@ namespace relational
{
namespace relational = relational::schema;
+ struct schema_emitter: relational::schema_emitter
+ {
+ schema_emitter (const base& x): base (x) {}
+
+ virtual void
+ pre ()
+ {
+ first_ = true;
+ }
+
+ virtual void
+ line (const std::string& l)
+ {
+ if (first_)
+ first_ = false;
+ else
+ os << endl;
+
+ last_ = l;
+ os << l;
+ }
+
+ virtual void
+ post ()
+ {
+ if (!first_) // Ignore empty statements.
+ {
+ if (last_ == "END;")
+ os << endl
+ << '/' << endl;
+ else
+ os << ';' << endl
+ << endl;
+ }
+ }
+
+ private:
+ bool first_;
+ string last_;
+ };
+ entry<schema_emitter> schema_emitter_;
+
//
// Drop.
//
@@ -44,6 +90,7 @@ namespace relational
<< " WHEN OTHERS THEN" << endl
<< " IF SQLCODE != -2289 THEN RAISE; END IF;" << endl
<< " END;" << endl
+ << " BEGIN" << endl
<< " EXECUTE IMMEDIATE 'DROP TRIGGER " <<
quote_id (table + "_trig") << "';" << endl
<< " EXCEPTION" << endl