summaryrefslogtreecommitdiff
path: root/odb/relational/source.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:45:31 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 11:47:15 +0200
commit20f2d671951ce2bf3e4b86d26e326e770733e421 (patch)
treee0ab66a82135a4e4be530d39fdbf77e2dc7bc17d /odb/relational/source.hxx
parent993a4a9b102161f9a5f52ea1d3f70e71307d626c (diff)
Add persist_stmt hook to handle generation of persist statement SQL
ODB requires that Oracle persist statements include a RETURNING clause so that a generated auto_id column value may be returned.
Diffstat (limited to 'odb/relational/source.hxx')
-rw-r--r--odb/relational/source.hxx37
1 files changed, 28 insertions, 9 deletions
diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx
index 52303ee..f18c51d 100644
--- a/odb/relational/source.hxx
+++ b/odb/relational/source.hxx
@@ -1974,6 +1974,12 @@ namespace relational
}
}
+ size_t
+ count () const
+ {
+ return count_;
+ }
+
private:
string& params_;
size_t count_;
@@ -2058,6 +2064,25 @@ namespace relational
}
//
+ // statements
+ //
+
+ virtual void
+ persist_stmt (type& c)
+ {
+ os << strlit ("INSERT INTO " + table_qname(c) + " (") << endl;
+
+ instance<object_columns> ct (false);
+ ct->traverse (c);
+
+ string values;
+ instance<persist_statement_params> pt (values);
+ pt->traverse (c);
+
+ os << strlit (") VALUES (" + values + ")");
+ }
+
+ //
// common
//
@@ -2308,17 +2333,11 @@ namespace relational
//
{
os << "const char " << traits << "::persist_statement[] " <<
- "=" << endl
- << strlit ("INSERT INTO " + table + " (") << endl;
+ "=" << endl;
- instance<object_columns> ct (false);
- ct->traverse (c);
+ persist_stmt (c);
- string values;
- instance<persist_statement_params> pt (values);
- pt->traverse (c);
-
- os << strlit (") VALUES (" + values + ")") << ";"
+ os << ";"
<< endl;
}