Running "SELECT getnextid('eperson') AS result" for about 40 times, fixed this.

For some reason there was a gap between few eperson_id's. Maybe some
had been deleted or so. But its strange, that getnextid
returned id's which were already in use. I had to manually run it
through all the id's before I could start entering new epersons in the
system.

Dont know if there is a bug in getnextid, but to me it seems to act strange.

Thanks for help,
Mika

2008/11/19 Robin Taylor <[EMAIL PROTECTED]>:
> Hi Mika,
>
> I remember asking myself exactly the same question :) but I can't remember 
> the answer ! I have just looked in the Dspace code and there is a bit that 
> looks like...
>
> ***************************************************************************
> // Get an ID (primary key) for this row by using the "getnextid"
>        // SQL function in Postgres, or directly with sequences in Oracle
>        String myQuery = "SELECT getnextid('" + table + "') AS result";
>
>        if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
>        {
>            myQuery = "SELECT " + table + "_seq" + ".nextval FROM dual";
>        }
> ****************************************************************************
>
>
>
> So I guess you need to enter...
>
> SELECT getnextid('eperson') AS result
>
>
> Good luck !
>
> Robin.
>
>
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> -----Original Message-----
> From: mikan.d.dspace listmail [mailto:[EMAIL PROTECTED]
> Sent: 19 November 2008 08:16
> To: Robin Taylor
> Subject: Re: [Dspace-tech] ERROR: duplicate key violates unique 
> constraint"eperson_pkey"
>
> Hi Robin,
>
> Thanks for the tip. When I try to run getnextid() from the sql prompt, I get 
> the following:
>
> dspace=# getnextid();
> ERROR:  syntax error at or near "getnextid" at character 1 LINE 1: 
> getnextid();
>
> or
>
> dspace=# getnextid(eperson_id);
> ERROR:  syntax error at or near "getnextid" at character 1 LINE 1: 
> getnextid(eperson_id);
>
> So how would I exactly need to run it?
> -Mika
>
>
> 2008/11/14 Robin Taylor <[EMAIL PROTECTED]>:
>> Hi Mika,
>>
>> The code that adds a new eperson record uses the 'getNextId' function of 
>> Postgres. So if you have 4 users...
>>
>> 1       Mika
>> 2       Robin
>> 3       Joe
>> 4       Jane
>>
>> Postgres should spot that 5 is the next available id and use that when 
>> adding a new eperson. Unfortunately if something goes wrong it can add the 
>> new record but not update the counter so it still thinks 5 is the next 
>> available id even though a record with 5 already exists. The easist way to 
>> fix it is to run the getnextid() function manually from an sql prompt. This 
>> will increment the counter by 1 to, hopefully, the truly next available id.
>>
>> Cheers, Robin.
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>>
>> -----Original Message-----
>> From: mikan.d.dspace listmail [mailto:[EMAIL PROTECTED]
>> Sent: 14 November 2008 12:47
>> To: [EMAIL PROTECTED]
>> Subject: [Dspace-tech] ERROR: duplicate key violates unique 
>> constraint"eperson_pkey"
>>
>> When trying to add e-person to DSpace 1.5.1 (with about 50 existing users)I 
>> get the following error:
>> org.postgresql.util.PSQLException: ERROR: duplicate key violates unique 
>> constraint "eperson_pkey"
>>
>> Something seems to be wrong with epersons, but how could I try to fix this? 
>> Where can I find the constaining column?
>>
>> Thanks,
>> Mika
>>
>> ----------------------------------------------------------------------
>> --- This SF.Net email is sponsored by the Moblin Your Move Developer's
>> challenge Build the coolest Linux based applications with Moblin SDK &
>> win great prizes Grand prize is a trip for two to an Open Source event
>> anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> DSpace-tech mailing list
>> DSpace-tech@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/dspace-tech
>>
>>
>>
>
>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech

Reply via email to