Cannot create a record in tablename. The record already exists. / Get new recid for a table
Views (8480)
I've seen this error a couple times within the past week after we migrated our data from PROD into DEV
"Cannot create a record in <table description> (<table name>). The record already exists."
What I was finding is the index was ok and everything was unique but for some odd reason we kept getting this error, even though I did a search on the data that was being inserted and it did not exist like the system was telling us.
What I figured out is sometimes the recid count gets messed up with transferring data and you need to reset it to a value greater than the max rec id of the current table. Here are the steps to fix it.
1. Create a Job to get the table id of the table having problems inserting data
static void GetTableIdFromNameJob(Args _args)
{
info(strFmt("%1", tableName2id("<table name>")));
}
2. In sql mgt studio
select max(recid) from <table name from step 1>
3. In sql mgt studio
Edit table SYSTEMSEQUENCES
Select the record where tabid = '<table id from info box in step 1>
Take the max id from step 2 and add 100 to it to be safe and update the field 'nextval' from systemsequences on the tableid you have selected.
4. Restart AOS (the changes will not take affect until you restart the AOS)
"Cannot create a record in <table description> (<table name>). The record already exists."
What I was finding is the index was ok and everything was unique but for some odd reason we kept getting this error, even though I did a search on the data that was being inserted and it did not exist like the system was telling us.
What I figured out is sometimes the recid count gets messed up with transferring data and you need to reset it to a value greater than the max rec id of the current table. Here are the steps to fix it.
1. Create a Job to get the table id of the table having problems inserting data
static void GetTableIdFromNameJob(Args _args)
{
info(strFmt("%1", tableName2id("<table name>")));
}
2. In sql mgt studio
select max(recid) from <table name from step 1>
3. In sql mgt studio
Edit table SYSTEMSEQUENCES
Select the record where tabid = '<table id from info box in step 1>
Take the max id from step 2 and add 100 to it to be safe and update the field 'nextval' from systemsequences on the tableid you have selected.
4. Restart AOS (the changes will not take affect until you restart the AOS)
This was originally posted here.

Like
Report
*This post is locked for comments