views:

37

answers:

1

Hello guys;

I think this question has been done before, but I don't find a clear answer. I have migrated SQl Server 2005 database to oracle 11. I am using subsonic 2.1. I have manged to create all the data layer classes, and generates everything well. But the problem turns up when I try to make an insert in the database: Oracle does not have autoincrement in the primary key unless you define a sequence and a trigger. In consequence, Subsonic defines all the Insert methods in the controller with the id column. Is there a way to avoid subsonic not generate Insert methods with the id column, which I am going to generate using a trigger and a sequence?

Thanks a lot

SToledo

UPDATE I finally did a horrible hack (I feel ashamed) in Subsonic 2.1 source code. I did modify OracleDataProvider to set id-named columns to be autoincrement to true. Then, the template will behave as I expect. I know is a terrible hack, but it works for me. Thanks for your help guys.

A: 

Don't know about Subsonic, but if number of tables is relatively small, you can modify BEFORE-INSERT trigger to disable nullity check:

CREATE OR REPLACE TRIGGER trig_BI
   BEFORE INSERT
   ON tab_name
   FOR EACH ROW
BEGIN
   --IF :NEW.key_column IS NULL
   --THEN
      SELECT tab_seq.NEXTVAL INTO :NEW.key_column FROM DUAL;
   --END IF;
END;
Alexander Malakhov
Thanks for the response, Alekxander. I will apply your advice. However, I was most concerned about code generation in SubSonic (a .NET ORM) than oracle's trigger, which works wellI will try to find a solution by myself.Thank you anywaySergio
SToledo