Re: SERIAL values

From: "Martin A(dot) Marques" <martin(at)math(dot)unl(dot)edu(dot)ar>
To: Kostis Mentzelos <mentzelos(at)ematic(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL values
Date: 2001-03-02 19:04:47
Message-ID: 983559887.3a9feecf7e7f7@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mensaje citado por: Kostis Mentzelos <mentzelos(at)ematic(dot)com>:

> Hi all,
>
> how can I get the current values from SERIAL types after an INSERT
> using
>
> libpq?

Don't know abou libpq, but the SERIAL type is managed by a sequence, and you can
get the current value of the sequence (can't recall, but I guess it's current).

Saludos... :-)

P.D.: If I'm making an insert and after it I want to insert another value
related with the serial inserted in the previous query to another table, which
aproche is better:

1) Get the oid of the last insert and use it to find the INT in the serial
column.
2) Get the current value in the sequence (I guess this is very bad, cause while
the first insert is finishing, another client can insert information on that
column, changing the current value on the sequence).
3) another solution?

System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Martín Marqués email: martin(at)math(dot)unl(dot)edu(dot)ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message adb 2001-03-02 19:07:38 Re: Re: Thought on OIDs
Previous Message Rod Taylor 2001-03-02 18:49:13 Re: Convert to upper