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

Re: Problem With Saving Parts



On Wed, 2009-12-09 at 05:54 -0800, Rich Shepard wrote:
> 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
> 

Hi Rich,
I'm afraid hacking about with the LSMB code is rather beyond me - in my
C programs I can cheat and stick it into a while(!successful) loop, but
real SQL ......

Cheers
Richard


> 
> ------------------------------------------------------------------------------
> Return on Information:
> Google Enterprise Search pays you back
> Get the facts.
> http://p.sf.net/sfu/google-dev2dev
> _______________________________________________
> Ledger-smb-users mailing list
> ..hidden..
> https://lists.sourceforge.net/lists/listinfo/ledger-smb-users