Migrating from MS SQL to Firebird

Posts   
 
    
Diego
User
Posts: 15
Joined: 06-Jul-2005
# Posted on: 06-Jul-2005 16:37:17   

Hello,

We are using the 1.0.2004.2 version of the LLBLGen Pro, and I'm evaluating Firebird 1.5 to replace our SqlServer (DataEngine version). We want to migrate our LLBL application to Firebird.

Everything seems to work OK except autogenerated keys (identity). And we use a lot of them having an Identity Primary Key in almost every table of our DataBase.

Firebird documentation suggests using triggers and generators to assign new values but LLBLGen has problems refetching these new values.

This code that works fine with SqlServer, using Firebird with tirggers and generators throws an exception.


              DataAccessAdapter adapter = new DataAccessAdapter();
          DetailEntity detail = new InternalUserEntity();
          detail.Text = "something";
              adapter.SaveEntity(detail, true);
          adapter.Dispose();
          int detailId = detail.Id;

The error occurs in the adapter.SaveEntity line.

Later we found that you don't encourage using triggers at all confused .

Posted on: 13-okt-2004 20:29:54 I've added a note to the section where the PK sequencing is mentioned and I've explained that triggers, default constraints and newid constructs will not make the value be read back simple_smile It was indeed somewhat confusing. For example on Firebird, it's common practise to use a trigger to insert a sequence value, which will cause wrong results, as the PK value is always 1 higher than the value initially inserted due to the trigger (so the entity will never be read back simple_smile )

The other option according to Firebird doccumentation is to use a stored procedure to retrieve a new value from a generator before saving the entity. Ussing this option would force us to change all our code.

Is there some other way of doing this that would allow us to migrate without forcing us to do a major code restructure?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 06-Jul-2005 17:38:14   

You should define generators, then refresh the catalog and then per entity, set a field (the PK field for example) to be an identity field and select the generator from the dropdownlist simple_smile then re-generate teh code and it should work.

Frans Bouma | Lead developer LLBLGen Pro
Diego
User
Posts: 15
Joined: 06-Jul-2005
# Posted on: 06-Jul-2005 21:41:47   

It works. I think I need to study the desinger a little more. flushed

Thanks!