I want to get type of column from postgresql trigger function.
This query returns type of items:
Select pg_typeof(shape) from sde.my_points;
And this query returns type of geometry:
Select GeometryType(shape) from sde.my_points;
I want to use this parts in postgresql trigger function:
CREATE FUNCTION point_xy() RETURNS trigger AS $point_xy$
BEGIN
IF (SELECT pg_typeof(NEW.shape)) = ('geometry')
AND GeometryType(NEW.shape) = ('POINT')
THEN
NEW.x = st_x(NEW.shape);
NEW.y = st_y(NEW.shape);
END IF;
END IF;
RETURN NEW;
END
$point_xy$ LANGUAGE plpgsql;
This function gives error, in this line (SELECT pg_typeof(NEW.shape)).
ERROR: invalid input syntax for type oid: "geometry"
QUERY: SELECT (SELECT pg_typeof(NEW.shape)) = ('geometry') AND GeometryType(NEW.shape) = ('POINT')
CONTEXT: PL/pgSQL function point_xy() line 7
How can I use in function?