[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem With Saving Parts



On Wed, 9 Dec 2009, beamends wrote:

"DBD::Pg::st execute failed: ERROR: duplicate key violates unique
constraint "partsvendor_pkey" at LedgerSMB/IC.pm line 529.

Error!

INSERT INTO partsvendor
(vendor_id, parts_id,
partnumber, lastcost,
leadtime, curr)
VALUES (?, ?, ?, ?, ?, ?)
ERROR: duplicate key violates unique constraint "partsvendor_pkey"
"

Richard,

  I'm not a perl coder, nor a LSMB developer, but I've encountered this type
of SQL error in my approximate reasoning models. The problem is the existing
key and the solution is to write the SQL statement as:

  INSERT or REPLACE into ...

  If the primary key does not exist the new row is inserted; else if the primary
key exists, the column attribute values are replaced with those in the
statement.

  An alternative approach to accomplishing the same thing is to first "DELETE
from <tablename> where ..." followed by the INSERT statement.

HTH,

Rich