E
E
er122015-09-18 10:33:30
MySQL
er12, 2015-09-18 10:33:30

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;

When I call it I get an error
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 ** ********

Please tell me what is wrong

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2015-09-18
@MaxDukov

an extremely strange choice of tags for the question .... what does MSSQL and MySQL have to do with it?
in fact - how do you call the function?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question