Need help in generating sequence numbers in BTEQ script

Database
Enthusiast

Need help in generating sequence numbers in BTEQ script

Hello,

I am a requirement to generate a sequence numer(e.g 000000000000,000000000001 etc) (the columns should be 12digits). 

Query :

SEL

CAST(COALSCE (A.COL1 )) AS COL1,

.

.

.

SEQ_ID_COL --> (here the number should get generated)

FROM

TAB1 INNER JOIN TAB2 .....

I am thinking to create a File(.txt that contains 000000000000) and import to a volatile table(VT1) and use this table in 

the col4(sel id from vt1) as SEQ_ID_COL,  and at the end the script we need to write a statment where the incremented 

value should get updated to the file and so the whole process runs.I am not sure of how to implement this and also if it is the right approach.

Can anyone please help me out in this.Thanks in Adv

Lalitha 

1 REPLY
Enthusiast

Re: Need help in generating sequence numbers in BTEQ script

Hi Lalitha,

I am not clear with the requirement. If this seq id is for a table then you can try like this:

      SEQ_ID_COL BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY

           (START WITH 000000000000 

            INCREMENT BY 1 

            MINVALUE -999999999999999999 

            MAXVALUE 999999999999999999 

            NO CYCLE),

 or if it's for a script you can default for the first time and increment by 1 from that column value from next load onwards.