I am trying to create a function in PL\pgSQL procedural language of two geometric data types, multipoint and multiline string for example. I want to select all lines within 30 meter distance for all points. Here is what I have tried:
Create OR Replace Function get_streets(bar.geom geometry foo.geom geometry)
Returns geometry AS $$
BEGIN
IF ST_DWithin(bar.geom, foo.geom, 30.0) Then
Return foo.geom;
ELSE
Return null;
END IF
Return foo.geom;
END;
$$ Language plpgsql;
The function returns an error because of geometry data type. Any advice for using/handling geometry data in plpgsql functions?