problem wit hsequence as primary key
От | Rob Brown-Bayliss |
---|---|
Тема | problem wit hsequence as primary key |
Дата | |
Msg-id | 1027658012.5551.11.camel@everglade.zoism.org обсуждение исходный текст |
Ответы |
Re: problem wit hsequence as primary key
|
Список | pgsql-general |
Hi, I was insertingrows into a table and had this error: Cannot insert a duplicate key into unique index stock_transactions_pkey Now the primary key is inserted by this function: CREATE FUNCTION "set_primary_key" () RETURNS text AS ' DECLARE sequence_number text; location_number text; retval text; BEGIN location_number := to_char(get_loc_key(),''999MI''); location_number := trim(both '' '' from location_number); sequence_number := to_char(nextval(''location_seq''),''99999MI''); sequence_number := trim(both '' '' from sequence_number); retval := location_number || ''-'' || sequence_number; RETURN retval; END; ' LANGUAGE 'plpgsql'; which results in valuse like 12-1234 as a text primary key. The location_seq is up to 100005 at the moment so how am I getting duplicate primary keys? -- * * Rob Brown-Bayliss *
В списке pgsql-general по дате отправления: