Reputation: 1111
I'm trying to use
SELECT currval('myTable_Orderid_seq');
I got error: currval not supported.
Any work around this is much appreciated. I need to use currval for each users' session in a multi user environment.
Upvotes: 1
Views: 1006
Reputation: 13725
If currval is not available (yet) in the session you can do this:
select last_value from myTable_Orderid_seq
From the doc: http://www.postgresql.org/docs/current/static/sql-createsequence.html
Although you cannot update a sequence directly, you can use a query like:
SELECT * FROM name;
to examine the parameters and current state of a sequence. In particular, the last_value field of the sequence shows the last value allocated by any session. (Of course, this value might be obsolete by the time it's printed, if other sessions are actively doing nextval calls.)
Upvotes: 3