Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    Question Unanswered: How are you using the SEQUENCE object ?

    How are you using the SEQUENCE object in your daily practice ?

    It's interesting to me.

    Give me some ideas, different from identify field.

    Thanks, Lenny

  2. #2
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    Query is working good...

    This query is working good:

    Code:
    drop SEQUENCE SEQ1;
    
    CREATE SEQUENCE SEQ1
           START WITH 1
           INCREMENT BY 1
    
    With TestTbl (seq#, str) as 
    (
    select 1, '000002050'
      from sysibm.sysdummy1
    union all
    select 2, '760000090'
      from sysibm.sysdummy1
    union all
    select 3, '005000001'
      from sysibm.sysdummy1
    union all 
    select 4, '090005000'
      from sysibm.sysdummy1
    union all
    select 5, '070000400'
      from sysibm.sysdummy1
    union all
    select 6, '000100080'
      from sysibm.sysdummy1
    union all
    select 7, '800000900'
      from sysibm.sysdummy1
    union all
    select 8, '230050060'
      from sysibm.sysdummy1
    union all
    select 9, '040601000'
      from sysibm.sysdummy1
    ) 
    select NEXT VALUE FOR SEQ1 nextseq, seq#, str
    From TestTbl
    Lenny

  3. #3
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    Thumbs down But this query is not good (SQLCODE = -348)

    This query doesn't work:

    Code:
    With TestTbl (seq#, str) as 
    (
    select 1, '000002050'
      from sysibm.sysdummy1
    union all
    select 2, '760000090'
      from sysibm.sysdummy1
    union all
    select 3, '005000001'
      from sysibm.sysdummy1
    union all 
    select 4, '090005000'
      from sysibm.sysdummy1
    union all
    select 5, '070000400'
      from sysibm.sysdummy1
    union all
    select 6, '000100080'
      from sysibm.sysdummy1
    union all
    select 7, '800000900'
      from sysibm.sysdummy1
    union all
    select 8, '230050060'
      from sysibm.sysdummy1
    union all
    select 9, '040601000'
      from sysibm.sysdummy1
    ) 
    select t1.nextseq, t1.seq#, t1.str 
    from 
    (select NEXT VALUE FOR SEQ1 nextseq, seq#, str
      From TestTbl ) t1
    SQL0348N "NEXT VALUE FOR SEQ1" cannot be specified in this context. SQLSTATE=428F9

    State:428F9,Native:-348,Origin:[IBM][CLI Driver][DB2]
    Lenny

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by Lenny77 View Post
    How are you using the SEQUENCE object in your daily practice ?

    It's interesting to me.

    Give me some ideas, different from identify field.

    Thanks, Lenny
    It's not very different from an identity column. When you create an identity column that is generated by default/always, then DB2 creates a sequence to manage it.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  5. #5
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    Red face Not clear

    Quote Originally Posted by Marcus_A View Post
    It's not very different from an identity column. When you create an identity column that is generated by default/always, then DB2 creates a sequence to manage it.
    Thank you, Marcus !

    It was the first that I have thought up....

    But not all so is simple even this way of application....

    Look the previous message.

    Lenny

Posting Permissions

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