OK, we're back to a mysql error.
the following code will print to the screen, the actual values for each col. But when I tell it to insert to the db, it makes hundreds of records have the same $serial.
Code:
my $input_machine_data=$dbhconnect->prepare("INSERT into customer_machines
( customer_id
, serial_number
, date_of_purchase
, last_updated
, last_updated_by
)
values (?,?,?,'','' ) ")
or die "prepare Failed on: $srv\n\t$DBI::errstr\n";
and it gives me an error of
Code:
Cannot add or update a child row:
a foreign key constraint fails
(`db_name/customer_machines`,
CONSTRAINT `customer_fk` FOREIGN KEY (`customer_id`)
REFERENCES `customer_details` (`customer_id`)
) at transfer_from_main_table_to_others.pl line 71.
I know what I am about to write seems to argue with mysql but, I have no duplicate rows. The customer_id PK is part of a composite key and so would be different anyway with the other values changing - wouldn't it?
The customer_id is different in every record anyway since it is being retrieved from the source table.
I must be missing something ~ perhaps that the customer_id value is 'sticking' just like the $serial var.

bazz
Bookmarks