I have Postgres SQL function defined like below. It has a part where it runs a select query and has to store it in v_combination_exists
variable. But it gives error in select statement.
ERROR: Array value must start with "{" or dimension information.malformed array literal: "Check_ID1"
ERROR: malformed array literal: "Check_ID1"
SQL state: 22P02
Detail: Array value must start with "{" or dimension information.
Context: PL/pgSQL function abc.check_ids(character varying[]) line 19 at SQL statement
Function definition:
CREATE OR REPLACE FUNCTION abc.check_ids(
id_values character varying[])
RETURNS void
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
v_combination_exists text[];
BEGIN
...
select id_value from abc.tableABC -- <-line 19
AND id_value = ANY(id_values)
INTO v_combination_exists;
IF v_combination_exists exists THEN
RAISE EXCEPTION 'The combination of provided fields already exists : %s', v_combination_exists ;
END IF;
END;
$BODY$;
The way I am calling this function:
select abc.check_id(p_client_id_values := ARRAY['Check_ID1','Check_ID2']);
Can someone please help in resolving the error?