[postgis-users] Distance function error if outside the boundary

Tom Melhuish tmelhuish at webinsightsinc.com
Fri Jul 30 09:20:24 PDT 2004


I'm executing the following Postgis DISTANCE function and if I select
the spatial object within the distance boundary the command works fine,
but I get the following error message in the Postgresql log:

            ERROR:  cursor "mycursor" does not exist

 

When I select the spatial object out side the command fails and I get
the following in the Postgresql log file.

ERROR:  syntax error at or near ")" at character 144

LOG:  could not send data to client: Connection reset by peer

LOG:  could not send data to client: Broken pipe

LOG:  unexpected EOF on client connection

The Apache log gives me:

      Premature end of script headers:

 

If  I copy either SQLcommand  and execute it in psql it runs fine. With
no error messages in the postgresql log file.  

 

Below is the code snippet

++++++++++++++++++++++++++++++++++++++++

$SQLcommand=qq(SELECT layer, ncpin, mapsheet, ownername, addr1, addr2,
addr3, city, state, zip, book, page, value, acreage, pflag, revalue,
market  FROM  jccondo WHERE the_geom &&
GeometryFromText('BOX3D(2103178.38307993 558215.2516,2173267.36692007
611928.4437)',1) AND Distance(GeometryFromText('POINT(2170383.04659743
579103.715194444)',1),the_geom) < 1401.77967680279);

 

my $stmt = $dbh->prepare($SQLcommand) ||  &AppletMsg("The table name
doesn't exist or one of the attrribute names are not valid...
$GisDataSrc","error");

      

$stmt->execute() or  &AppletMsg("Can't execute select items on
$GisDataSrc - $DBI::errstr ","error");

 

$colctr=1;

      

while (@tname = ($stmt->fetchrow_array())) {

      foreach $value (@tname) {

 

            if  ($colctr == $NumAttrItems+1 ){

                  $ItemNum++;

                  $colctr=1;

            }

            $QueryResultsmatrix[$ItemNum]->[$colctr]=$value


            $colctr++;

      }

}

 

$stmt->finish();

++++++++++++++++++++++++++++++++++

      

If I need to define a cursor, can someone please send an example or edit
my code to define how this may be done using DBI. 

 

Thanks in advance for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040730/1d196a84/attachment.html>


More information about the postgis-users mailing list