Thread: Continue sequence

Continue sequence

From
Wilton
Date:
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

Re: Continue sequence

From
Devrim GUNDUZ
Date:
Hi,

On Fri, 2007-01-05 at 11:13 -0200, Wilton wrote:
> Which is the correct way to obtain a continue sequence without fail
> (hole/gap) for a composite-id ?

http://www.varlena.com/GeneralBits/130.php

may help you.

Regards,

--
The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/




Attachment

Re: Continue sequence

From
Jorge Godoy
Date:
Wilton <wilton.wonrath@microwork.inf.br> writes:

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

http://www.google.com.br/search?q=gapless+sequence+postgresql

Since the first hits -- at Varlena -- aren't accessible you can use google's
cache:

http://209.85.165.104/search?q=cache:wCm4AMkEbA4J:www.varlena.com/GeneralBits/130.php+gapless+sequence+postgresql


--
Jorge Godoy      <jgodoy@gmail.com>