<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<br>
<br>
I am developing an interface for a PostreSQL/PostGIS (v8.2) database
using Mapserver (v 5.2.0) and Java (v6.0).<br>
I obtained some nice maps using a basic SQL query, inserted into the
mapfile.<br>
<br>
But as soon as I tried to <u>use some simple quote <b>'</b> or <b>\'</b></u>,
the server cannot draw the layer and report the following error :<br>
<br>
<pre>java.lang.UnknownError: msPOSTGISLayerRetrievePK(): Query error. Error executing POSTGIS statement (msPOSTGISLayerRetrievePK():select attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid = pg_class.oid and pg_class.oid = pg_attribute.attrelid and pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum and pg_class.relname = '<i><b>REQUEST REMOVED</b></i>' and pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null
        edu.umn.gis.mapscript.mapscriptJNI.layerObj_draw(Native Method)
        edu.umn.gis.mapscript.layerObj.draw(layerObj.java:472)
        fr.ird.remige.bean.MapFileBean$layerItemClass.draw(MapFileBean.java:617)
        fr.ird.remige.bean.MapFileBean.draw(MapFileBean.java:1105)

</pre>
REQUEST REMOVED was something like :<br>
<pre>g_carre5 from (select distinct g_carre5 from carre 
inner join date using (id_date)
inner join country using (id_country) 
WHERE v_date BETWEEN 2000 AND 2001 AND <u><b>l_country='France'</b></u>
group by g_carre5) as foo</pre>
The previous request, which was working, was :<br>
<pre>g_carre5 from (select distinct g_carre5 from carre 
inner join date using (id_date)
inner join country using (id_country) 
WHERE v_date BETWEEN 2000 AND 2001 AND <u><b>v_country=1</b></u>
group by g_carre5) as foo</pre>
<u><br>
Table country :</u><br>
id_country serial primary key<br>
v_country numeric(4)<br>
l_country varchar(12)<br>
<br>
And first line is id_country = 1, v_country = 1, l_country = France.<br>
<br>
One strange thing is that, when I am using a mapfile script on my
computer (not on the server) and transform it into an image file with <b>shp2img</b>
(shell command), both requests are working. Moreover, both requests are
also working with SQL command, when logged into the database.<br>
<br>
In Java, the string containing the request is : "g_carre5 from (select
distinct g_carre5 from carre inner join date using (id_date) inner join
country using (id_country) WHERE v_date BETWEEN 2000 AND 2001 AND
l_country=\'France\' group by g_carre5) as foo". <br>
<br>
I also tried to replace <b>\' </b>by <b>\"</b>, and the expected
error <i><b>column "France" does not exist</b></i> was reported, which
shows that Libmapscript.so translated <b>\"</b> correctly.<br>
<br>
I do not understand why there is this quoting issue. Does somebody have
ever dealt with something like that?<br>
<br>
Julien<br>
<br>
</body>
</html>