INSERT操作の実行後にテーブルを返す2つの関数(duplicate_iofsとduplicate_ioftypes)を宣言しました。
CREATE OR REPLACE FUNCTION duplicate_iofs(IN iof_group_src_id integer, IN iof_group_dst_id integer)
RETURNS TABLE(src_id integer, new_id integer) AS $$
BEGIN
-- DO INSERT REQUESTS
END;
CREATE OR REPLACE FUNCTION duplicate_ioftypes(IN iof_group_src_id integer, IN iof_group_dst_id integer)
RETURNS TABLE(src_id integer, new_id integer) AS $$
BEGIN
-- DO INSERT REQUESTS
END;
3番目の関数でそのようなことをどのように行うことができますか?
-- 1. Call duplicate_iofs(...) and store the result table (e.g. iofs_table)
-- 2. Call duplicate_ioftypes(...) and store the result table (e.g. ioftypes_table).
-- 3. Iterate through 'iofs_table' and 'ioftypes_table' with nested loops :
FOR iof_row IN SELECT * FROM iofs_table LOOP
FOR ioftype_row IN SELECT * FROM ioftypes_table LOOP
-- DO SOMETHING
END LOOP;
END LOOP;
注:duplicate_iofs()およびduplicate_ioftypes()は1回だけ呼び出す必要があるため、ネストされたループに呼び出さないでください。