Results 1 to 8 of 8

Thread: Sequence

  1. #1
    Join Date
    Dec 2004
    Posts
    54

    Angry Unanswered: Sequence

    Hi,

    Can anyone tell me where I can get all sequence's current value?


    Allian

  2. #2
    Join Date
    Aug 2004
    Posts
    330
    Identity_val_local()

  3. #3
    Join Date
    Jul 2003
    Location
    Austin, TX, USA
    Posts
    278

    Sysibm.syssequences

    hi.

    I think you can get the same also by querying SYSIBM.SYSSEQUENCES table.

    You can query the lastassignedval for the seqname.
    HTH

    Nitin

    Ask the experienced rather than the learned

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by urquel
    Identity_val_local()
    IDENTITY != SEQUENCE

  5. #5
    Join Date
    Aug 2004
    Posts
    330
    My bad. I guess I should read ALL of the words.

  6. #6
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Nitin ,
    The lastassignedval in the SYSIBM.SYSSEQUENCES gives the last cached value and not the last assigned one ..
    Cheers
    Sathyaram

    C:\>db2 "create sequence seq2"
    DB20000I The SQL command completed successfully.


    C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

    LASTASSIGNEDVAL
    ---------------------------------
    -

    1 record(s) selected.


    C:\>db2 "values(nextval for seq2)"

    1
    -----------
    1

    1 record(s) selected.


    C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

    LASTASSIGNEDVAL
    ---------------------------------
    20.

    1 record(s) selected.


    C:\>db2 "values(nextval for seq2)"

    1
    -----------
    2

    1 record(s) selected.


    C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

    LASTASSIGNEDVAL
    ---------------------------------
    20.

    1 record(s) selected.


    C:\>
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  7. #7
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    To answer the original question
    PREVVAL FOR <sequence-name>
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  8. #8
    Join Date
    Jul 2003
    Location
    Austin, TX, USA
    Posts
    278

    Cobweb Cleared.

    Thanks Sathyaram for the wonderful explanation.

    You have cleared a lot of cobwebs for many of us with your wonderful example.

    Appreciate that!
    HTH

    Nitin

    Ask the experienced rather than the learned

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •