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

Tom Melhuish tmelhuish at webinsightsinc.com
Tue Aug 3 10:51:45 PDT 2004


I'm executing the following Postgis SQL command and if I select the
spatial object within the distance the command works, 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:

 

The problem I'm having is that I can't trap the error using an "eval"
statement in perl. The $stmt->execute()is where I'm having problems. The
command seams to execute OK but when I try to  test for $@ or  print out
$@ or try a ($stmt->fetchrow_array() I get a "Premature end of script
headers:" error and the program dies with no opportunity to trap the
error. 

 

Can anyone help in showing me a way to trap this error or what I may be
doing wrong? It appears that "mycusror" is declared in the select
statement but maybe lost in the execution part. 

 

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);

 

eval {

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

};

if ($@) {

&AppletMsg("The table name doesn't exist or one of the attribute names
are not valid... $@","error <mailto:$@%22,%22error> ");

}

 

eval {      

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

};

if ($@) {

&AppletMsg("Can't execute select items... $@","error
<mailto:$@%22,%22error> ");

}

 

$colctr=1;

      

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

      foreach $value (@tname) {

 

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

                  $ItemNum++;

                  $colctr=1;

            }

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

      }

}

 

$stmt->finish();

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

 

I'm running the following versions:

    Postgis 0.8.1

    Postgresql 7.4.1

    DBI    1.40

    Redhat 9.0

 

Please let me know if I need to provide any other information to help
debug the program. 

 

Thanks in advance for your help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040803/36f271d7/attachment.html>


More information about the postgis-users mailing list