配列またはレコードをpostgreSQLの関数に渡しますか?
-
16-10-2019 - |
質問
Array、Records、および場合によっては、PostgreSQLで機能するパラメーターとして、レコードの配列を渡すタスクがあります。
解決
Postgresには非常に柔軟な取り扱いがあります 配列 と 複合型. 。これはあなたがやろうとしているようなことかもしれません:
create type my_type as (val1 integer, val2 integer);
create function my_function(arr my_type[]) returns text language plpgsql as $$ begin return arr::text; end;$$;
select my_function(array[row(1,2),row(3,4)]::my_type[]);
| my_function | | :---------------- | | {"(1,2)","(3,4)"} |
dbfiddle ここ
所属していません dba.stackexchange