Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Database Error 1452: unable to insert a new work order
05-27-2022, 09:56 PM,
#1
Database Error 1452: unable to insert a new work order
I can't invoice for a particular product. I get an error, Cannot add or update a child row: a foreign key constraint fails

Database Error 1452 : Unable to insert a new work order for the sales order item
Cannot add or update a child row: a foreign key constraint fails (`DB`.`workorders`, CONSTRAINT `worksorders_ibfk_1` FOREIGN KEY (`loccode`) REFERENCES `locations` (`loccode`))

Database Rollback Due to Error Above : Rolling Back Transaction OK

/DeliveryDetails.php?identifier=1653646435
Reply
05-28-2022, 07:34 AM,
#2
RE: Database Error 1452: unable to insert a new work order
(05-27-2022, 09:56 PM)wissedenis22 Wrote: I can't invoice for a particular product. I get an error, Cannot add or update a child row: a foreign key constraint fails

Database Error 1452 : Unable to insert a new work order for the sales order item
Cannot add or update a child row: a foreign key constraint fails (`DB`.`workorders`, CONSTRAINT `worksorders_ibfk_1` FOREIGN KEY (`loccode`) REFERENCES `locations` (`loccode`))

Database Rollback Due to Error Above : Rolling Back Transaction OK

/DeliveryDetails.php?identifier=1653646435
can anyone help to make things clear. I see this
PHP Code:
($ErrMsg _('Unable to insert a new work order for the sales order item')) 
was included inĀ  DeliveryDetails.php

what does this mean, did I miss something in a primary table. Kindly help, any suggestion
Reply
05-28-2022, 02:09 PM, (This post was last modified: 05-28-2022, 02:10 PM by TurboPT.)
#3
RE: Database Error 1452: unable to insert a new work order
I'll check this tomorrow to see what may be the situation, but does the item have a loccode?
Reply
05-31-2022, 01:33 AM, (This post was last modified: 05-31-2022, 01:35 AM by TurboPT.)
#4
RE: Database Error 1452: unable to insert a new work order
Looking to the handling, is anything set for Default Factory Location at menu Setup => System Parameters?

The value to that setting is set to:
PHP Code:
$_SESSION['DefaultFactoryLocation'
...which is used as the loccode reference for the workorder insert at line 504 in DeliveryDetails.php.
Reply
05-31-2022, 04:04 AM,
#5
RE: Database Error 1452: unable to insert a new work order
(05-31-2022, 01:33 AM)TurboPT Wrote: Looking to the handling, is anything set for Default Factory Location at menu Setup => System Parameters?

The value to that setting is set to:
PHP Code:
$_SESSION['DefaultFactoryLocation'
...which is used as the loccode reference for the workorder insert at line 504 in DeliveryDetails.php.
Yeah I can see there a default factory location set, so what do you advice
Reply
05-31-2022, 07:03 AM, (This post was last modified: 05-31-2022, 09:01 AM by TurboPT.)
#6
RE: Database Error 1452: unable to insert a new work order
I found that message is actually at 2 places in the DeliveryDetails file, so line 504 may not be the only place that can be the trouble.

Do you mind adding a couple of echo's to check?
If you might not have any local file modifications, I can attach a file with debug added, if that might be more desirable.

Anyway, add this before the query at line 499:
PHP Code:
echo __FILE__':'__LINE__" => wo: $WONo, loccode: {$_SESSION['DefaultFactoryLocation']}, end."

Add this before the query at line 697:
PHP Code:
echo __FILE__':'__LINE__" => wo: $WONo, loccode: {$_SESSION['Items'.$identifier]->Location}, end."


Then save, reproduce the error, to see what output displays on the page.

Also, check the loccode at the table level to ensure that it does not possibly have any leading/trailing white space that could cause a mismatch.
Can use this query, but replace the zzz portion with the known loccode:
Code:
SELECT loccode, length(loccode) FROM locations WHERE loccode like '%zzz%';
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)