[postgis-users] plpgsql build BOX3D

Stephen Woodbridge woodbri at swoodbridge.com
Wed Nov 2 09:57:26 PST 2005


Miguel,

you are trying to return a text string representation of a BOX3D not a 
box3d, so try:

RETURN GeomFromText('BOX3D....');

-Steve W.

Miguel de la Fuente wrote:
> Hello everybody, I want to do a function that receives as param two 
> points and returns a box3d from this points, I have tried but I can't do it.
> This is my function
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> CREATE OR REPLACE FUNCTION getprueba1("numeric", "numeric")
>   RETURNS BOX3D AS
> $BODY$  
> BEGIN
> RETURN 'BOX3D('||($1-100)::VARCHAR ||' 
> '||($2-100)::varchar||','||($1+100)::VARCHAR||' 
> '||($2+100)::varchar||')'::BOX3D;
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE;
> ALTER FUNCTION getprueba1("numeric", "numeric") OWNER TO postgres;
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> This is the error
>  
> ERROR:  BOX3D parser - doesnt start with BOX3D(
> CONTEXT:  SQL statement "SELECT  'BOX3D('||( $1 -100)::VARCHAR ||' '||( 
> $2 -100)::varchar||','||( $3 +100)::VARCHAR||' '||( $4 
> +100)::varchar||')'::BOX3D"
> PL/pgSQL function "getprueba1" line 3 at return
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
> 
> can anybody help me, I can't find where is the error, If I do the same 
> with a literal string this works, but when I use the pipe for concat 
> strings this doesnt work.
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list