[postgis-users] Problem with syntax in function

Ludovico Bianchini metlud at yahoo.it
Wed May 23 01:45:05 PDT 2007


Great!, both solutions work!

-SQL
CREATE OR REPLACE FUNCTION
myschema.sel_by_pos2(varchar, varchar, varchar,
varchar)
RETURNS SETOF myschema.mytable AS
$BODY$select * from myschema.mytable where
(geom_column
 && GeomFromText('POLYGON((' || $1 || ' ' || $2 || ',
' || $1 || ' ' || $4 || ', ' || $3 || ' ' || $4 || ',
' ||  $3 || ' ' || $2 || ', ' || $1 || ' ' || $2 ||
'))', 26591));
$BODY$
LANGUAGE 'sql' VOLATILE;

-plpgsql
CREATE OR REPLACE FUNCTION
myschema.sel_by_pos(varchar, varchar, varchar,
varchar)
RETURNS SETOF myschema.mytable AS
$$
DECLARE
        str text;
    rec record;
BEGIN
        str := 'select * from myschema.mytable where
(geom_column
 && SetSRID(''BOX3D(' || $1 || ' ' || $2 || ', ' || $3
||
 ' ' || $4 || ')''::box3d, 26591))';
       
    -- For debugging only
        raise notice 'str is: %', str;

    for rec in execute str loop
        return next rec;
    end loop;

END
$$ LANGUAGE 'plpgsql' VOLATILE;

Thank you very much!


      ___________________________________ 
L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html



More information about the postgis-users mailing list