0

I was trying to find a solution for the key duplication error in Wt::Dbo + PostgreSQL. I have seen many forums about this error, but didn't find a fix for Wt alone.

It will be really help full if somebody can provide a solution for the above problem.

Regards Ansif

ATTIC
  • 161
  • 2
  • 11

1 Answers1

0

I have applied the fix from the below link, How to reset postgres' primary key sequence when it falls out of sync?

In Wt, we have to do something like this. dbo::Query< dbo::ptr > query = session.query < dbo::ptr > ("SELECT setval(\"Tblname_id_seq\", COALESCE((SELECT MAX(id)+1 FROM \"Tablename\"), 1), false)");

dbo::ptr newRecord = session.add(new Tablename());

Regards Ansif

Community
  • 1
  • 1
ATTIC
  • 161
  • 2
  • 11