Continue sequence

From: Wilton Wonrath <wrwonrath(at)yahoo(dot)com(dot)br>
To: pgsql-general(at)postgresql(dot)org
Subject: Continue sequence
Date: 2007-01-05 17:30:46
Message-ID: 20070105173046.59157.qmail@web34304.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Which is the correct way to obtain a continue sequence without fail
(hole/gap) for a composite-id ?

Example:

CREATE TABLE nf

(

number INTERGER NOT NULL,

serie VARCHAR(2) NOT NULL,

CONSTRAINT pky_nf PRIMARY KEY (number,serie)

)

number serie

1 A

2 A

1 B

3 A

4 A

2 B

I think that I will need to use LOCK TABLE or SELECT FOR UPDATE, but in
both cases if the client terminal shutdown suddenly the tuple/table
stays locked on the server for a indeterminate time.

I did a test with the following commands using pgadmin III:

BEGIN;

LOCK TABLE nf IN EXCLUSIVE MODE;

I restarted my terminal and checked in another terminal that the LOCK
condition was there. After 10 minutes, to unlock the table, I send a
KILL command for the process that was locking the table/tuple.

Best regards,

Rogério Augusto Bassete - BRAZIL/SP

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Erik Jones 2007-01-05 18:14:18 More activity in pg_stat_activity
Previous Message Jeanna Geier 2007-01-05 16:22:38 Re: Deleting From View?