I have created a user-defined type in PostgreSQL(version 11.5).
CREATE TYPE key_type AS (key_no character varying(50), key_nm character varying(128));
I created below function with an input parameter of type key_type[] and output as TEXT.
create or replace function fn_net(inp IN key_type[]) returns TEXT as........
But I am unable to call the function, I have tried as below.
do
$$
declare
v_key key_type[];
v_res TEXT;
begin
v_key.key_no := '709R';
v_key.key_nm := 'Risk';
select * from fn_det(v_key) into v_res;
raise notice '%', v_res;
end;
$$
language plpgsql;
I get malformed array error or function does not exist error. Please help me as to how to pass the inputs correctly.
NOTE: I am able to run successfully if I specify input type as key_type instead of key_type[] but I need array type for the requirement.