PREVIOUS VALUE FOR sequence_name
or in Oracle mode (SQL_MODE=ORACLE)
PREVIOUS VALUE FOR is IBM DB2 syntax while
LASTVAL() is PostgreSQL syntax.
Get last value generated from a sequence.
- If the sequence has not yet been used by the connection,
PREVIOUS VALUE FORreturns
- If a
SEQUENCEhas been dropped and re-created then it's treated as a new
PREVIOUS VALUE FORwill return
- FLUSH TABLES
has no affect onPREVIOUS VALUE FOR
- Previous values for all used sequences are stored per connection until connection ends.