From 4b664a84adc4ffdf131c8b02b0c7c56eed281baa Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 20 Oct 2011 10:33:55 +0200 Subject: Correct generation of Oracle sequences and triggers for auto increment columns --- odb/relational/oracle/schema.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'odb/relational') 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); -- cgit v1.1