I have an array of strings and I need to loop through the array; while looping for each string, I need to loop up the ID of that string in a table and create an INT array of those IDs.
Effectively, I need to go FROM:
{"a", "b", "c"}
TO:
{3,6,8}
I am getting this loop going with no errors, and I get the correct ID for each string in the original array, but I have an empty array declared which does not seem to get populated... This is the code
First raise notive gives me the correct privilege_group_id, but the second raise notice still returns an empty array.. so no concat happens. I tried ARRAY_APPEND() with the same results, always an empty array.
Any thoughts on what I am doing wrong?
select array_agg(privilege_group_id FROM privilege_group WHERE privilege_group_code = any(a_existing_user_group_codes)