Getting Sequence Value

From: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Getting Sequence Value
Date: 2019-01-23 00:43:10
Message-ID: CAAY=A78gDhsiY4TkedccBxqQ2StY9ee9khqqt2x2zuc+=vA+sg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I need to get the sequence value of a table before inserting a new record,
so I am using *currval, *but I am getting an error stating that "currval is
not defined for this session". I tried using *nextval*, but the sequence
skips one value because *nextval* increments by one and also an additional
increment is preformed by the *insert* operation.

How can I get the next available value avoiding these issues?

Regards,
Jorge Maldonado

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2019-01-23 00:58:07 Re: Getting Sequence Value
Previous Message Tomasz Barszczewski 2019-01-22 12:11:46 Re: PostgreSQL database for GITLAB - Must it use the public schema?