Somehow my code only insert row 1 and colum1,2,3 records into output table.
unfortutely it doesn’t insert records row2 onwards.
could someone please help?
unforutely my code only insert the first row’s column only.
it is not iterating through remaing rows to get corrsponding coulmns inserted into the output table.
code is as below:
create or replace procedure proc3()
returns varchar
language javascript
as
$$
var query1= 'select * from test2'
var query1_s = snowflake.createStatement({sqlText: query1});
var query1_s_res = query1_s.execute();
for (i = 1; i <= query1_s_res.getRowCount(); i++){
query1_s_res.next()
X= query1_s_res.getColumnValue(1)
Y = query1_s_res.getColumnValue(2)
Z = query1_s_res.getColumnValue(3)
var sql_source_table =
"INSERT INTO test3 VALUES (?,?,?)";
var source_max_day = snowflake.execute ({sqlText: sql_source_table, binds: [X,Y,Z]});
return "Done";}
$$
;
call proc3()
2
Answers
You have defined the return statement inside the for loop, at the end. This is the cause only iterate one time.
Remove it, and put outside the loop.