Question

I am using navicat function builder to build a new simple function:

SELECT st_dimension(geometry)
FROM nature

I want to take the result of the POSTGIS st_dimension function using the table nature and the column geometry that contains geometries as multipolygons.

The return type schema is pg_catalog and the return type is int4

This is the SQL preview:

  CREATE FUNCTION "public"."NewProc"(IN  "public"."geometry")
  RETURNS "pg_catalog"."int4" AS $BODY$SELECT st_dimension(geometry)
  FROM nature$BODY$
  LANGUAGE 'plpgsql' VOLATILE;

When i am trying to save it a get this error:

ERROR: syntax error at or near "SELECT" LINE2: RETURNs "pg_catalog"."int4" AS $BODY$SELECT... ^

I tried to do the same with the build in function st_dimension() that it has, with parameter nature.geometry but i get the error:

Procedure execution failed ERROR: missing FROM-clause entry for table "natura" LINE 1: ... "public"."st_dimension(""public"".""geometry"")"(natura.geo... ^

What I am doing wrong with the above function?

Était-ce utile?

La solution

Language should be 'sql', not 'plpgsql'. It isn't clear why you have an IN parameter that is not used by the function. Furthermore, if nature.geometry has a mixture of dimensions, then it my return the result of a random row, since there is no ORDER BY clause.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top