I have this snippet of code:
RAISE NOTICE 'p_new_roster: %', p_new_roster; --prints {3,4,5}
FOREACH i IN ARRAY p_new_roster
LOOP
RAISE NOTICE 'p_new_roster[i]: %', p_new_roster[i]; --prints 5,NULL,NULL (through 3 iterations)
v_new_users := v_new_users || p_new_roster[i];
END LOOP;
How come p_new_roster[1] is 5, p_new_roster[2] is NULL, etc.? Variable i is declared as integer, and arrays are declared as integer[].
Basically what I am trying to do is clone 'p_new_roster' array. If somebody knows better way, I would like to know how too.
v_new_users = p_new_roster
. What's the actual problem you're trying to solve by doing this, the "why" for the "how" you're asking here? – Craig Ringer 2 days ago