Thanks Ola. The "nextval" function is definitely useful.
Cheers. Busoye On 25 April 2013 08:13, Ola Hodne Titlestad <[email protected]> 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<https://maps.google.com/maps?q=Eftas%C3%A5sen+68,+0687+Oslo,+Norge&hl=en&ie=UTF8&sll=59.893855,10.785116&sspn=0.222842,0.585709&oq=eftas%C3%A5sen+68,+0687+Oslo,+&t=h&hnear=Eftas%C3%A5sen+68,+%C3%98stensj%C3%B8,+0687+Oslo,+Norway&z=16> > > > On 25 April 2013 01:23, Thuy Nguyen <[email protected]> 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 <[email protected]>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 : [email protected] >>> Unsubscribe : https://launchpad.net/~dhis2-users >>> More help : https://help.launchpad.net/ListHelp >>> >>> >> >> _______________________________________________ >> Mailing list: https://launchpad.net/~dhis2-users >> Post to : [email protected] >> Unsubscribe : https://launchpad.net/~dhis2-users >> More help : https://help.launchpad.net/ListHelp >> >> >
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-users Post to : [email protected] Unsubscribe : https://launchpad.net/~dhis2-users More help : https://help.launchpad.net/ListHelp

