| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

11-16-09, 17:17
|
|
Registered User
|
|
Join Date: Jul 2009
Location: NY
Posts: 886
|
|
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
|
|

11-17-09, 17:01
|
|
Registered User
|
|
Join Date: Jul 2009
Location: NY
Posts: 886
|
|
|
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
|
|

11-17-09, 17:09
|
|
Registered User
|
|
Join Date: Jul 2009
Location: NY
Posts: 886
|
|
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
Quote:
SQL0348N "NEXT VALUE FOR SEQ1" cannot be specified in this context. SQLSTATE=428F9
State:428F9,Native:-348,Origin:[IBM][CLI Driver][DB2]
|
Lenny
|
|

11-17-09, 18:22
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
Originally Posted by Lenny77
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
|
|

11-18-09, 10:27
|
|
Registered User
|
|
Join Date: Jul 2009
Location: NY
Posts: 886
|
|
Not clear
Quote:
Originally Posted by Marcus_A
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|