Answer the question
In order to leave comments, you need to log in
What is the correct way to return an array in a PostgreSql function?
i have a function
CREATE OR REPLACE FUNCTION disp.t(x integer,e character varying) RETURNS integer [] AS
$$
DECLARE
service_id_actual integer [];
BEGIN
...
if xage=x then service_id_actual:=array_append(service_id_actual, service_id_model_age::json->'f1'); end if;
return service_id_actual;
...
EXCEPTION WHEN others THEN
return false;
END;
$$
LANGUAGE plpgsql VOLATILE
COST 100;
ERROR: array value must start with "{" or dimension specification
CONTEXT: PL/pgSQL function disp.t(integer,character varying), when casting return value to function result type
********** Error ** ********
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question