pretty new to teradata and trying to figure out how to repeat a simple insert statement.
I have the following statement
Insert into Test (Id) values ((sel max (Id)+1 from test))
And I would to repeat this 20 times.
pretty new to teradata and trying to figure out how to repeat a simple insert statement.
I have the following statement
Insert into Test (Id) values ((sel max (Id)+1 from test))
And I would to repeat this 20 times.
For the purposes of running the statement 20 times
create table test_table_1 ( numcol int );
replace procedure test_proc()
begin
declare rowcnt int;
set rowcnt = 0;
while rowcnt<20 do
begin
insert into test_table_1 select max(coalesce(numcol,null,0))+1 from test_table_1;
set rowcnt = rowcnt + 1;
end;
end while;
end;
call test_proc();
select * from test_table_1;
But in reality you would simply need an identity column which would preclude the need to insert incremental value 20 times.