No Deferred Constraints

Posts   
 
    
DCollard
User
Posts: 15
Joined: 09-Feb-2006
# Posted on: 09-Feb-2006 13:22:54   

I get errors when users change values with Unique Key contraints. The example below demonstrates the problem:

ID (PK) DESC(UK) 1 GB 2 USA

Within .Net 2005 application, I change this to:

ID (PK) DESC(UK) 1 USA 2 GB

When I try to write this back to the SQLServer2005 database, I get an error because the UK has been violated. Is there a way to tell either SQLServer or the ORM framework to defer the constraint until the commit?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 09-Feb-2006 13:50:52   

no, as this is a DB thing.

Frans Bouma | Lead developer LLBLGen Pro
DCollard
User
Posts: 15
Joined: 09-Feb-2006
# Posted on: 09-Feb-2006 15:41:16   

Will this also mean that in the more complex case where I have a parent / child relationship in which a parent/child record is removed and a new parent / child record are added I will encounter a similar issue because:

1) If the parent object is persisted first, the deleted child will fail the FK constraint as it becomes orphaned until it is deleted

2) If the child object is persisted first, the added child will fail the FK constraint as it will be orphaned until its parent is added.

Or does LLBLGEN Pro have a way to work around this?

Kind Regards,

Darren Collard

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 09-Feb-2006 16:14:28   

It's a generic database issue. Most common solution is that you temporarily set the fk field to NULL, then update it later on with a new value.

Frans Bouma | Lead developer LLBLGen Pro