Skip to content

Instantly share code, notes, and snippets.

@cnukaus
Last active March 16, 2023 23:52
Show Gist options
  • Save cnukaus/0bdda47d74e1487636c8fb90976b0527 to your computer and use it in GitHub Desktop.
Save cnukaus/0bdda47d74e1487636c8fb90976b0527 to your computer and use it in GitHub Desktop.
create or preplace procedure `proc_name`
BEGIN
declare k_array ARRAY<struct><banner string, intiative_type string>;
set k_array =
(
select array_agg(meta) from
(SELECT struct(banner,initiative_type) as meta
from storing_table
) t
);
for element in (
select * from unnest(k_array)) DO
EXECUTE IMMEDIATE format(
""" SELECT '%s' # this is arg1
""",
element.banner.element.initiative_type
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment