lastval()
Synopsis
Use the lastval()
function to return the value returned from the last call to nextval()
, for any sequence, in the current session.
Semantics
- An error is raised if
nextval()
has not been called in the current session.
Examples
Create two sequences and call nextval()
for each of them.
yugabyte=# CREATE SEQUENCE s1;
CREATE SEQUENCE
yugabyte=# CREATE SEQUENCE s2 START -100 MINVALUE -100;
CREATE SEQUENCE
yugabyte=# SELECT nextval('s1');
nextval
nextval
1
(1 row)
yugabyte=# SELECT nextval('s2');
nextval
nextval
-100
(1 row)
Call lastval()
.
yugabyte=# SELECT lastval()
lastval
lastval
-100
(1 row)
See also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .