Adding New Indicators results in Duplicate value in PKey Violation Error

Hi all,

I imported 190 new indicators through a csv import into Postgres. IndicatorID as the primary key was set incrementally to continue from the last highest number (i.e. 33466, 33467, 33468 … 33673). The imported indicators work perfectly.

Now the problem: I tried to create a new indicator through the front end in DHIS2.11 (Build Revision: 10492) but keep getting an error that identifies a primary key conflict with the indicatorid. I also found that with every retry, the system tries to use the next incremental indicatorid (e.g. trial 1: indicatorid 33467 already exists; trial 2: 33468 already exists). I manually entered the indicator directly into the postgres table without any problem. Again, the indicator works fine. Any ideas on how to solve this problem without having to update all the imported indicators with new indicator ids?

Further details of the error are attached in the attached screenshots (for some reason my tomcat log is not capturing the error - also attached).

Thanks.

Busoye

DHIS Version: 2.11

Build Revision: 10492

OS: Windows XP

OS Version: 5.1

image

image

image

localhost.2013-04-24.log (15.9 KB)

catalina.2013-04-24.log (36.6 KB)

Hi Busoye

You can change the current value of hibernate sequence by open your postgresql database> there you expand the Schemas >

expand the Sequences> right click on Hibernate_sequence and select Properties. the Current Value is in the Definition tab.

Change this number to the highest id from your indicator table or highest in all the id value you have in the database to prevent this error happen again in future.

Thuy

···

On Thu, Apr 25, 2013 at 3:38 AM, Busoye Anifalaje busoye@hisp.org wrote:

Hi all,

I imported 190 new indicators through a csv import into Postgres. IndicatorID as the primary key was set incrementally to continue from the last highest number (i.e. 33466, 33467, 33468 … 33673). The imported indicators work perfectly.

Now the problem: I tried to create a new indicator through the front end in DHIS2.11 (Build Revision: 10492) but keep getting an error that identifies a primary key conflict with the indicatorid. I also found that with every retry, the system tries to use the next incremental indicatorid (e.g. trial 1: indicatorid 33467 already exists; trial 2: 33468 already exists). I manually entered the indicator directly into the postgres table without any problem. Again, the indicator works fine. Any ideas on how to solve this problem without having to update all the imported indicators with new indicator ids?

Further details of the error are attached in the attached screenshots (for some reason my tomcat log is not capturing the error - also attached).

Thanks.

Busoye

DHIS Version: 2.11

Build Revision: 10492

OS: Windows XP

OS Version: 5.1


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Hi Thuy,

Worked perfectly.

Thank you.

Busoye

···

On 25 April 2013 00:23, Thuy Nguyen thuy.hispvietnam@gmail.com wrote:

Hi Busoye

You can change the current value of hibernate sequence by open your postgresql database> there you expand the Schemas >

expand the Sequences> right click on Hibernate_sequence and select Properties. the Current Value is in the Definition tab.

Change this number to the highest id from your indicator table or highest in all the id value you have in the database to prevent this error happen again in future.

Thuy

On Thu, Apr 25, 2013 at 3:38 AM, Busoye Anifalaje busoye@hisp.org wrote:

Hi all,

I imported 190 new indicators through a csv import into Postgres. IndicatorID as the primary key was set incrementally to continue from the last highest number (i.e. 33466, 33467, 33468 … 33673). The imported indicators work perfectly.

Now the problem: I tried to create a new indicator through the front end in DHIS2.11 (Build Revision: 10492) but keep getting an error that identifies a primary key conflict with the indicatorid. I also found that with every retry, the system tries to use the next incremental indicatorid (e.g. trial 1: indicatorid 33467 already exists; trial 2: 33468 already exists). I manually entered the indicator directly into the postgres table without any problem. Again, the indicator works fine. Any ideas on how to solve this problem without having to update all the imported indicators with new indicator ids?

Further details of the error are attached in the attached screenshots (for some reason my tomcat log is not capturing the error - also attached).

Thanks.

Busoye

DHIS Version: 2.11

Build Revision: 10492

OS: Windows XP

OS Version: 5.1


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Hi,

When you say csv import into postgres you mean that you manually imported the indicators using sql directly into your database?

We have something called csv import though the DHIS 2 interface as well, so was a bit confusing.

All ids in the database get the values from the hibernate_sequence and if you manually insert ids without paying attention to this sequence you will end up with inconsistencies as you have now experienced.

When doing manual inserts directly on the database in sql you can use the nextval(‘hibernate_sequence’) function to set the ids. This will keep the postgres/hibernate sequence in order and make sure DHIS 2 will get the next correct ids as well.

Then there is no need to set the ids manually or to manually set the hibernate_sequence value.

Ola

···

On Thu, Apr 25, 2013 at 3:38 AM, Busoye Anifalaje busoye@hisp.org wrote:

Hi all,

I imported 190 new indicators through a csv import into Postgres. IndicatorID as the primary key was set incrementally to continue from the last highest number (i.e. 33466, 33467, 33468 … 33673). The imported indicators work perfectly.

Now the problem: I tried to create a new indicator through the front end in DHIS2.11 (Build Revision: 10492) but keep getting an error that identifies a primary key conflict with the indicatorid. I also found that with every retry, the system tries to use the next incremental indicatorid (e.g. trial 1: indicatorid 33467 already exists; trial 2: 33468 already exists). I manually entered the indicator directly into the postgres table without any problem. Again, the indicator works fine. Any ideas on how to solve this problem without having to update all the imported indicators with new indicator ids?

Further details of the error are attached in the attached screenshots (for some reason my tomcat log is not capturing the error - also attached).

Thanks.

Busoye

DHIS Version: 2.11

Build Revision: 10492

OS: Windows XP

OS Version: 5.1


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Thanks Ola.

The “nextval” function is definitely useful.

Cheers.

Busoye

···

On 25 April 2013 08:13, Ola Hodne Titlestad olati@ifi.uio.no wrote:

Hi,

When you say csv import into postgres you mean that you manually imported the indicators using sql directly into your database?

We have something called csv import though the DHIS 2 interface as well, so was a bit confusing.

All ids in the database get the values from the hibernate_sequence and if you manually insert ids without paying attention to this sequence you will end up with inconsistencies as you have now experienced.

When doing manual inserts directly on the database in sql you can use the nextval(‘hibernate_sequence’) function to set the ids. This will keep the postgres/hibernate sequence in order and make sure DHIS 2 will get the next correct ids as well.

Then there is no need to set the ids manually or to manually set the hibernate_sequence value.

Ola



Ola Hodne Titlestad (Mr)

HISP
Department of Informatics
University of Oslo

Mobile: +47 48069736
Home address: Eftasåsen 68, 0687 Oslo, Norway. Googlemaps link

On 25 April 2013 01:23, Thuy Nguyen thuy.hispvietnam@gmail.com wrote:

Hi Busoye

You can change the current value of hibernate sequence by open your postgresql database> there you expand the Schemas >

expand the Sequences> right click on Hibernate_sequence and select Properties. the Current Value is in the Definition tab.

Change this number to the highest id from your indicator table or highest in all the id value you have in the database to prevent this error happen again in future.

Thuy


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

On Thu, Apr 25, 2013 at 3:38 AM, Busoye Anifalaje busoye@hisp.org wrote:

Hi all,

I imported 190 new indicators through a csv import into Postgres. IndicatorID as the primary key was set incrementally to continue from the last highest number (i.e. 33466, 33467, 33468 … 33673). The imported indicators work perfectly.

Now the problem: I tried to create a new indicator through the front end in DHIS2.11 (Build Revision: 10492) but keep getting an error that identifies a primary key conflict with the indicatorid. I also found that with every retry, the system tries to use the next incremental indicatorid (e.g. trial 1: indicatorid 33467 already exists; trial 2: 33468 already exists). I manually entered the indicator directly into the postgres table without any problem. Again, the indicator works fine. Any ideas on how to solve this problem without having to update all the imported indicators with new indicator ids?

Further details of the error are attached in the attached screenshots (for some reason my tomcat log is not capturing the error - also attached).

Thanks.

Busoye

DHIS Version: 2.11

Build Revision: 10492

OS: Windows XP

OS Version: 5.1


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp