| From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
|---|---|
| To: | JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Getting the current value of a sequence |
| Date: | 2015-04-23 11:46:54 |
| Message-ID: | 20150423114654.GA19543@depesz.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Thu, Apr 23, 2015 at 06:17:42AM -0500, JORGE MALDONADO wrote:
> I have been trying to get the current value of a sequence without success.
> I have read that "currval" does the job but I do not know how to use it.
> This is what I have tried and I get an error saying that "currval of
> sequence 'name_of_sequence' is not defined for the session.
>
> SELECT currval('name_of_sequence')
> I will very much appreciate your feedback.
You can use currval() only after you used nextval() - in the same db
session.
Why do you want to use currval() before? What is the use case?
Best regards,
depesz
--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Roxanne Reid-Bennett | 2015-04-23 13:12:26 | Re: Getting the current value of a sequence |
| Previous Message | JORGE MALDONADO | 2015-04-23 11:17:42 | Getting the current value of a sequence |