summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-20 10:33:55 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-21 11:47:15 +0200
commit4b664a84adc4ffdf131c8b02b0c7c56eed281baa (patch)
tree869066bc11ab1c1f1a6821e4ca15a7343e83f792
parent19247f9be2c29274087af1e96a672c83b5d03833 (diff)
Correct generation of Oracle sequences and triggers for auto increment columns
-rw-r--r--odb/relational/oracle/schema.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx
index 029b51c..8a10d2e 100644
--- a/odb/relational/oracle/schema.cxx
+++ b/odb/relational/oracle/schema.cxx
@@ -301,19 +301,27 @@ namespace relational
{
string seq_name (quote_id (name + "_seq"));
+ pre_statement ();
+
os_ << "CREATE SEQUENCE " << seq_name << endl
- << " START WITH 1 INCREMENT BY 1;" << endl;
+ << " START WITH 1 INCREMENT BY 1" << endl
+ << endl;
+
+ post_statement ();
+
+ pre_statement ();
os_ << "CREATE TRIGGER " <<
quote_id (name + "_trig") << endl
<< " BEFORE INSERT ON " << quote_id (name) << endl
<< " FOR EACH ROW" << endl
<< "BEGIN" << endl
- << " SELECT " << seq_name << ".nextval INTO :new. " <<
+ << " SELECT " << seq_name << ".nextval INTO :new." <<
column_qname (*id) << " FROM DUAL;" << endl
- << "END;";
- }
+ << "END;" << endl;
+ post_statement ();
+ }
object_columns_references ocr (e_, os_, name);
ocr.traverse (c);