[Mapserver-users] accessing numeric fields in postgres

Oliver Wesp wesp at gdv.com
Mon Mar 31 05:54:00 PST 2003


Dear List,

I'm playing aroung with postgres and I am stuck with simple class 
expressions and query functions when there is numeric data involved.

Here is my connection string:

   CONNECTION "user=testuser dbname=testdb host=192.168.1.1"
   DATA 'the_geom from TOWNS'

If I use a class expression on a text field (varchar) everything works fine:

CLASS
         EXPRESSION ('[NAME]' eq '[Koblenz]')
.
.
.
END

But if I use numeric data I didn't get it to work. For example

CLASS
         EXPRESSION ([POPULATION] gt 100000)
.
.
.
END

results in:

msPOSTGISLayerWhichShapes(): Query error. prep_DB:Error executing POSTGIS 
DECLARE statement (0.6 failed - retried 0.5 and it failed too). DECLARE 
mycursor BINARY CURSOR FOR SELECT 
population::text,asbinary(force_collection(force_2d(the_geom)),'NDR'),OID::text 
from TOWNS WHERE the_geom && setSRID('BOX3D(2437855.645172 
5385619.37645828,2759898.898962 5673838.37484672)'::BOX3D, 
find_srid('','TOWNS','the_geom') )

Looks like mapserver tries to cast the numeric field POPULATION to text. If 
I test the SELECT statement within the database it says: Cannot cast type 
'numeric' to 'text'. If I change population::text to population::numeric it 
works fine.

Same is for query/nquery if there are numeric fields in the table.

Am I missing something? Is there a problem with my postgres installation? I 
tried quotes on every possible position of the expression without  success.

any hint is appreciated
Oliver

-- 
Dipl.-Geogr. Oliver Wesp
Gesellschaft für geografische Datenverarbeitung
Binger Strasse 49-51
D-55218 Ingelheim
fon: +49 6132 714818
fax: +49 6132 714828
http: <http://www.gdv.com>www.gdv.com





More information about the MapServer-users mailing list