Page 1 of 1

FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Wed Apr 30, 2008 10:46 am
by bobr2k
I was checking some shipping conditions - I set up a multiple shipping locations condition, printed it out, then did not follow up by closing out the order or backing out and I'm throwing an exception ... yesterday we saw a similar problem - we cleared the cart database and resolved the problem. That one had a valid reason: Items in the cart for a product with options, removed the options without clearing the database.

Today I'm getting this:
INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{StoreName}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{StoreName}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated.
I can get to other pages but when I do anything related to add cart, or view cart the message reoccurs. Is there a way to reset the cart without having to call my database guy? Could this be a bug?

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Wed Apr 30, 2008 11:07 am
by bobr2k
I believe it's a bug. I just repeated the process: added a few items to the cart, ship a couple items to multiple destinations, accepted the fedex over 21 statement, while viewing the payment page I clicked on my account, clicked on manage addresses, clicked new ...

got this:
[[ConLib:MyAddressBookPage]] INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'ac_Warehouses_ac_BasketShipments_FK1'. The conflict occurred in database '{store name}', table 'ac_Warehouses', column 'WarehouseId'. The statement has been terminated.

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Thu May 01, 2008 6:44 am
by AbleMods
Bob, by any chance have you deleted a warehouse recently?

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Thu May 01, 2008 12:35 pm
by bobr2k
Yep - I had to follow the method offered here:
viewtopic.php?f=42&t=6540&p=29599&hilit ... ods#p29599
Apparently when you delete a warehouse the logic does not delete related segments which would no longer be valid before deleting the warehouse record so I had some old items and some new items in my cart (added after the warehouse change) and got to a situation where it hiccuped. I don't think a person should have to be aware of a situation like that - those segments could and probably should be deleted behind the scenes.

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Thu May 01, 2008 12:56 pm
by AbleMods
bobr2k wrote:I don't think a person should have to be aware of a situation like that - those segments could and probably should be deleted behind the scenes.
It has to do with the key constraints configured in the database. Able still has a few minor tweaks to make to get it completely cleaned up. I had the same thing happen to me with a payment method many months ago.

I would report it to Able so they can get the system more tolerant of deleted warehouses.

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Thu May 01, 2008 2:38 pm
by bobr2k
I would report it to Able so they can get the system more tolerant of deleted warehouses.
consider it done! 8)

Re: FOREIGN KEY constraint 'ac_Warehouses ?Bug or ??

Posted: Thu May 08, 2008 9:50 am
by sohaib
Although still unverified a bug has been entered in our bug database for further investigation.
Marked for 7.1