insert into problem in BTEQ

Tools & Utilities
WAQ
Enthusiast

insert into problem in BTEQ

i want to insert some values in my table using INSERT INTO SELECT SQL as:

INSERT INTO tableName (col1, col2, col3)
SELECT col2, col3 FROM tableName;

for col1 i need to pass the value comming from file (using (:next_var)) and increment it for every row comming from the SELECT.
How to do this?
2 REPLIES
Junior Contributor

Re: insert into problem in BTEQ

INSERT INTO tableName (col1, col2, col3)
SELECT :next_var + row_number () over (order by ???)
col2, col3 FROM tableName;

Dieter
WAQ
Enthusiast

Re: insert into problem in BTEQ

thanks it works, i was doing as
SELECT :next_var + 1 col2, col3 FROM tableName; but it was using the same value for every row but now i got what the problem was.
Thanks anyway