 |
 |
Archives of the TeradataForum
Message Posted: Thu, 31 Jan 2002 @ 15:51:53 GMT
Subj: | | Re: Sequences |
|
From: | | John K. Wight |
You can use the OLAP function CSUM to generate them and even add on from the Master table. Here is an example to try:
INSERT INTO
DBSpace.TableA
(
ROW_UNIQUE_SEQ
,TRANS_DATE
,CORPID
...
,PRODUCT_CODE
)
SELECT
TATSK.StartKey + CSUM(1,CORPID,..., PRODUCT_CODE)
,STAR.TRANS_DATE
,STAR.CORP_ID
....
,STAR.PRODUCT_CODE
FROM
(
SELECT MAX(ROW_UNIQUE_SEQ) as StartKey
FROM
DBSpace.TableA
) AS TATSK
,DBSpace.TableA STAR
Make sure the attributes you use in the Sort Expression of the CSUM will be as unique as you can get them - maybe use the PK columns of
the input table to sort. Also note, that there is no join condition to the derived table as you want this to be a CROSS JOIN (Cartesian
Product).
Hope this works for you.
| |