diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-20 10:33:55 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-10-21 11:47:15 +0200 |
commit | 4b664a84adc4ffdf131c8b02b0c7c56eed281baa (patch) | |
tree | 869066bc11ab1c1f1a6821e4ca15a7343e83f792 | |
parent | 19247f9be2c29274087af1e96a672c83b5d03833 (diff) |
Correct generation of Oracle sequences and triggers for auto increment columns
-rw-r--r-- | odb/relational/oracle/schema.cxx | 16 |
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); |