I have a pure SQL function like this:
CREATE OR REPLACE FUNCTION get_buildings_by_type(
building_types TEXT
)
RETURNS TABLE (bldg_id TEXT, "SurfArea" FLOAT, geom GEOMETRY) AS
$$
SELECT
bldg."OBJECTID"::TEXT AS bldg_id,
bldg."SurfArea"::FLOAT,
bldg.geom
FROM
static.buildings AS bldg
WHERE
bldg."LandUse" = $1
$$
LANGUAGE SQL;
And it behaves as expected, everything is working. However, I would like to have it work with an input array of building_types, rather than a single values. When I try this instead:
CREATE OR REPLACE FUNCTION get_buildings_by_type(
building_types TEXT[]
)
RETURNS TABLE (bldg_id TEXT, "SurfArea" FLOAT, geom GEOMETRY) AS
$$
SELECT
bldg."OBJECTID"::TEXT AS bldg_id,
bldg."SurfArea"::FLOAT,
bldg.geom
FROM
static.buildings AS bldg
WHERE
bldg."LandUse" IN $1
$$
LANGUAGE SQL;
I get a syntax error:
ERROR: syntax error at or near "$1"
LINE 15: bldg."LandUse" IN $1
Any ideas?
The version is 9.6 if that is relevant.
inoperator is not for arrays, @a_horse_with_no_name posted the correct answer