PostgreSQL: Issue with passing array to procedure

后端 未结 2 1581
悲哀的现实
悲哀的现实 2020-12-22 08:46

I have a type as:

CREATE TYPE status_record AS
   (
   id bigint,
   status boolean
   );

A procedure that does some processing with an arr

2条回答
  •  攒了一身酷
    2020-12-22 09:42

    Use an array literal (text representation of the array), since the array constructor ARRAY[...] has to be evaluated by Postgres:

    SELECT update_status('{"(1,t)","(2,f)"}'::status_record[]);
    

    Maybe even without the explicit cast:

    SELECT update_status('{"(1,t)","(2,f)"}');
    

    There were similar cases on SO before:

    • Pass array from node-postgres to plpgsql function
    • How to pass custom type array to Postgres function

提交回复
热议问题