Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 31 Jan 2002 @ 15:51:53 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


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.



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 27 Dec 2016