I'm trying to get the value of multiple columns in an array and set them as a variable that can be used in the loop to do something else. Thanks.
DECLARE the_array ARRAY<STRUCT<value1 STRING,value2 STRING>>;
SET the_array = (
SELECT ARRAY_AGG(STRUCT(value1,value2))
FROM `project.dataset.table`
WHERE somthing = 'somthing'
);
LOOP
SET i = i + 1;
SET var1 = the_array[ORDINAL(????)]; // what do I do here?
SET var2 = the_array[ORDINAL(???)]; // what do I do here?
IF i > ARRAY_LENGTH(the_array) THEN
LEAVE;
END IF;
insert into `project.dataset.other_table` values(var1,var2);
END LOOP;