aebstract Posted January 11, 2010 Share Posted January 11, 2010 violation of FOREIGN KEY constraint "INTEG_618" on table "SOITEM" Foreign key reference target does not exist INSERT INTO SOITEM (SOITEM.ID, SOITEM.PRODUCTID, SOITEM.SOID, SOITEM.TYPEID, SOITEM.STATUSID, SOITEM.UOMID, SOITEM.SOLINEITEM, SOITEM.DESCRIPTION, SOITEM.PRODUCTNUM, SOITEM.CUSTOMERPARTNUM, SOITEM.TAXABLEFLAG, SOITEM.QTYTOFULFILL, SOITEM.QTYFULFILLED, SOITEM.QTYPICKED, SOITEM.DATELASTFULFILLMENT, SOITEM.DATESCHEDULEDFULFILLMENT, SOITEM.REVLEVEL, SOITEM.REPAIRFLAG, SOITEM.TBDPRICEFLAG, SOITEM.EXCHANGESOLINEITEM, SOITEM.QBCLASSID, SOITEM.NOTE, SOITEM.SHOWITEMFLAG, SOITEM.ITEMADJUSTID, SOITEM.UNITPRICE, SOITEM.TOTALPRICE, SOITEM.ADJUSTAMOUNT, SOITEM.TOTALCOST) SELECT '1459', '991', SOITEM.SOID, '20', SOITEM.STATUSID, SOITEM.UOMID, '3', 'Restocking Fee', 'Restocking Fee', SOITEM.CUSTOMERPARTNUM, SOITEM.TAXABLEFLAG, SOITEM.QTYTOFULFILL, SOITEM.QTYFULFILLED, SOITEM.QTYPICKED, SOITEM.DATELASTFULFILLMENT, SOITEM.DATESCHEDULEDFULFILLMENT, SOITEM.REVLEVEL, SOITEM.REPAIRFLAG, SOITEM.TBDPRICEFLAG, SOITEM.EXCHANGESOLINEITEM, SOITEM.QBCLASSID, SOITEM.NOTE, SOITEM.SHOWITEMFLAG, SOITEM.ITEMADJUSTID, '29.74', '29.74', SOITEM.ADJUSTAMOUNT, SOITEM.TOTALCOST FROM SOITEM WHERE SOITEM.ID = '116' Excuse it for being so long and seeming to be a mess, it's only going to be manually ran once and never again. What could be causing this error? Quote Link to comment https://forums.phpfreaks.com/topic/188106-violation-of-foreign-key-constraint/ Share on other sites More sharing options...
Mchl Posted January 11, 2010 Share Posted January 11, 2010 There's a foreign key restraint defined on this table, which means a record in this table cannot exist without a record it references to in some other table. Use SHOW CREATE TABLE SOITEM to check what constraints are defined in this table. Quote Link to comment https://forums.phpfreaks.com/topic/188106-violation-of-foreign-key-constraint/#findComment-993159 Share on other sites More sharing options...
aebstract Posted January 12, 2010 Author Share Posted January 12, 2010 Oh man that's gonna really suck. I'm having to add a line to an order for something and I'm gonna have to track all the foreign keys down to the roots and all in sql. The database tool has a tab showing foreign keys, so I can just go by that but this should take a little while. There's 7 of them for this table, and I bet there's more on the others. Quote Link to comment https://forums.phpfreaks.com/topic/188106-violation-of-foreign-key-constraint/#findComment-993541 Share on other sites More sharing options...
aebstract Posted January 12, 2010 Author Share Posted January 12, 2010 Okay turned out I had a number wrong, changed it and matched up correctly. Now I get a new error though: violation of PRIMARY or UNIQUE KEY constraint "INTEG_617" on table "SOITEM" and with what I'm using you can't use show: Token unknown - line 1, column 1 SHOW Quote Link to comment https://forums.phpfreaks.com/topic/188106-violation-of-foreign-key-constraint/#findComment-993553 Share on other sites More sharing options...
aebstract Posted January 12, 2010 Author Share Posted January 12, 2010 Was simply my fault for not checking for the last ID again this morning. Everything is good. Quote Link to comment https://forums.phpfreaks.com/topic/188106-violation-of-foreign-key-constraint/#findComment-993576 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.