[postgis-users] Problem with pgsql function

palmerj at xtra.co.nz palmerj at xtra.co.nz
Thu Sep 21 17:42:48 PDT 2006


Hi,

I have had problems with creating a pgsql function:

CREATE OR REPLACE FUNCTION bde.shift_point(shape geometry)
  RETURNS GEOMETRY AS
$BODY$
    DECLARE
        x        DOUBLE PRECISION;
        y        DOUBLE PRECISION;
        z        DOUBLE PRECISION;
        srid     INTEGER;
        new      GEOMETRY;
    BEGIN
        IF ( geometrytype(shape) <> 'POINT' ) THEN
             RETURN NULL;
        END IF;
        x    := x(shape);
        y    := y(shape);
        z    := z(shape);
        srid := srid(shape);
        
        --RAISE NOTICE 'x=%, y=%, z=%, srid=%', x, y, z, srid;
        x   := x - 160;
        IF ( x  < -180 ) THEN
            x := x + 360;
        END IF;

        new := MakePoint( x, y, z);
        IF srid THEN
            new := SetSRID(new, srid);
        END IF;
        RETURN new;
    END;
$BODY$
  LANGUAGE 'plpgsql' IMMUTABLE;

I get the following error: 

ERROR:  syntax error at or near "(" at character 13
QUERY:  SELECT   $1 ( $2 )
CONTEXT:  SQL statement in PL/PgSQL function "shift_point" near line 11
LINE 1: SELECT   $1 ( $2 )

If I prefix the postgis x, y, z, setsrid functions with the schema 'public'. The function parses ok. 

My search path environment variables are:

public, bde, bdewtn, comp_test, unloads, gdbcrs, crsrpt, audit

my postgis version is:

POSTGIS="1.1.2CVS" GEOS="2.2.1-CAPI-1.0.1" PROJ="Rel. 4.4.9, 29 Oct 2004" USE_STATS

postgresql server version = 8.1.2 linux redhat 9.0

Thanks
Jeremy





More information about the postgis-users mailing list