I'm trying to create a postgresql. But I keep having an error
ERROR: operator does not exist: integer[] <@ integer Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
CREATE OR REPLACE FUNCTION accumulate_cs_order(int[][], int)
returns int[][]
language sql
as $f$
SELECT CASE
WHEN array[abs($2)] <@ $1[1] THEN -- If $2 has been closed pass
$1
WHEN $2 < 0 THEN -- elIf we're closing $2 add it to $1[1]
array[array_append($1[1], abs($2)), $1[2]]
WHEN $2 < $1[2] THEN -- ElIf we're not closing $2 and it is cheaper than $1[2], this is our new CS
array[$1[1], array[$2]]
ELSE
$1
END;
$f$;
I can't figure out why it is not working. I have declared my variables with the right types, array[abs($2)] <@ $1[1] makes sense to me, because $1[1] is an array, but postgresql seems to be thinking it is an int.