Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting next sequence value

Status
Not open for further replies.

blakmk

Programmer
Feb 12, 2003
17
GB
Does anyone know of a way to get the next value of a sequence without inserting it into a table.

Ie to get the value into a stored procedure variable.

Thanks in advance
Mark
 
blakmk,

SELECT NEXTVAL FOR sequence_name FROM table_expression WHERE something = something.

Any table expression should work.

I would suggest using SYSIBM.SYSDUMMY1 for your table expression along the lines of

SELECT NEXTVAL FOR sequence_name FROM SYSIBM.SYSDUMMY1 WHERE IBM_REQD='Y'

Unfortunately I don't have DB2 in front of me, so the statement is untested.

Cheers
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top