ERROR: duplicate key value violates unique constraint

 

james.hart's picture

Hi,

I am new to xTuple (and accounting for that matter.) I am trying to enter our beginning balances as instructed here: http://www.xtuple.org/EnteringOpeningBalances.

When I have finished entering the balances and I click POST, I get the following error:

ERROR: duplicate key value violates unique constraint "trialbal_pkey"
DETAIL: Key (trialbal_id)=(9149) already exists.
CONTEXT: SQL statement "INSERT INTO trialbal
( trialbal_id, trialbal_accnt_id, trialbal_period_id,
trialbal_beginning, trialbal_dirty,
trialbal_ending,
trialbal_credits,
trialbal_debits )
VALUES
( _trialbalid, _r.gltrans_accnt_id, _r.period_id,
0, TRUE,
_r.gltrans_amount,
CASE WHEN (_r.gltrans_amount > 0) THEN _r.gltrans_amount
ELSE 0
END,
CASE WHEN (_r.gltrans_amount < 0) THEN (_r.gltrans_amount * -1)
ELSE 0
END )"
PL/pgSQL function "postintotrialbalance" line 50 at SQL statement
SQL statement "SELECT postIntoTrialBalance(pSequence)"
PL/pgSQL function "postglseriesnosumm" line 96 at PERFORM

I don't know what this means or how to fix it. Does anyone know how to fix it?

Thank you!

 
james.hart's picture
Offline
Joined: 06/30/2012
Now I am getting the same

Now I am getting the same error while trying to update a user role's privileges:

ERROR: duplicate key value violates unique constraint "grppriv_pkey"
DETAIL: Key (grppriv_id)=(622) already exists.
CONTEXT: SQL statement "INSERT INTO grppriv
( grppriv_grp_id, grppriv_priv_id )
VALUES
( pGrpid, pPrivid )"
PL/pgSQL function "grantprivgroup" line 20 at SQL statement

 
james.hart's picture
Offline
Joined: 06/30/2012
.......

.......

 
james.hart's picture
Offline
Joined: 06/30/2012
Well... in the absence of any

Well... in the absence of any better suggestions, I backed up my database, fired up pgAdmin, and went poking around for a table called trialbal.

After awhile I did find a table called trialbal with about 2,500 entries, each with a $0 debit and a $0 credit entry. Since I didn't enter any financial transactions yet (I encountered this problem when I was entering the opening balances), I selected all the records in the trialbal table and deleted them. Then I tried again to post my opening balances and it posted without error!

Everything *seems* to be working normally for the last few days. I'm sure there is a better way to fix this problem, however I have don't know a better way. If anyone knows please share because I really want to know.

 
charlesschley's picture
Offline
Joined: 11/16/2010
Denver

James, I am local Xtuple partner here in Denver, give me a call and I can see if I can help you out with your issue.

Charles
303-809-0091
www.enterpriseicg.com