[postgis-users] Using DBI Placeholders for GeomFromText

P Kishor punk.kish at gmail.com
Fri Jun 11 21:36:51 PDT 2010


On Fri, Jun 11, 2010 at 11:27 PM, Stuart Gralton <sgralton at gmail.com> wrote:
> Hello Everybody,
>
> Is it possible to use Perl DBI placeholders to insert a geometry into a
> table using GeomFromText.
>
> When I try the following;
>
>      $sth = $dbh->prepare("INSERT INTO table (gid, the_geom) VALUES (?,?)");
>      $sth->execute(1, GeomFromText('POINT(1 1)', 4326));

untested, but you might want to try enclosing the literals in single
quotes... something like so
       $sth->execute(1, 'GeomFromText("POINT(1 1)", 4326)');

>
> an error is produced:
>
>      ERROR:  parse error - invalid geometry
>      HINT:  You must specify a valid OGC WKT geometry type such as POINT,
> LINESTRING or POLYGON
>
> The following statement works fine:
>
>      INSERT INTO table (gid, the_geom) VALUES (1, GeomFromText('POINT(1 1)',
> 4326));
>
>
> I am not entirely sure if this is more of a DBI question or a POSTGIS
> question, but maybe someone can help?
>
> Thanks,
>
> Stuart
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================



More information about the postgis-users mailing list