Problems with Postgis Query

Bjoern Platzen bjoern.platzen at MOMATEC.DE
Tue Aug 9 11:05:52 EDT 2005


Hello List!

from my postgis database I need two tables to visualize a layer:

CREATE TABLE arealocation
(
  geometryid int4 NOT NULL DEFAULT
nextval('"arealocation_geometryid_seq"'::text),
  geometrie geometry,
  CONSTRAINT pk_arealocation PRIMARY KEY (geometryid),
  CONSTRAINT enforce_geotype_geometry CHECK (geometrytype(geometrie) =
'POLYGON'::text OR geometrie IS NULL),
  CONSTRAINT enforce_srid_geometry CHECK (srid(geometrie) = -1)
) 
WITH OIDS;

CREATE TABLE all_qu
(
  quid int4 NOT NULL DEFAULT nextval('"all_qu_quid_seq"'::text),
  qunr int4,
  qust int4,
  quname varchar(50) DEFAULT ''::character varying,
  map_ext varchar(100) DEFAULT ''::character varying,
  mapfile varchar(20) DEFAULT ''::character varying,
  geometrytype varchar(25) DEFAULT 'arealocation'::character varying,
  geometrie int4,
  color varchar(7) NOT NULL DEFAULT ''::character varying,
  recdat int8 DEFAULT 0,
  cssurl varchar(100) DEFAULT ''::character varying,
  "session" varchar(50) DEFAULT ''::character varying
) 
WITH OIDS;

For each all_qu.quid there is a polygon in arealocations. The tables are
linked by the fields all_qu.geometrie and arealocation.geometryid.

The geometry_columns-table contains a row for the geometry in arealocation:
22422;"''";"public";"arealocation";"geometrie";"2";"-1";"POLYGON"

In my mapfile I've got the following statement:
DATA "geom FROM (SELECT a.quid as quid, a.quname AS name, a.color,
b.geometrie AS geom FROM arealocation b LEFT JOIN all_qu a ON b.geometryid =
a.geometrie) as foo using unique arealocation.geometryid using srid=-1"
The statement itself returns exately four rows, like it should.

Somehow, this does not work. I always get the following error-message (using
shp2img):
msDrawMap(): Image handling error. Failed to draw layer named
'plugin_Parkinfo_quartiere'. <br>
prepare_database(): Query error. Error executing POSTGIS DECLARE (the actual
query) statement: 'DECLARE mycursor BINARY CURSOR FOR SELECT
Id::text,name::text,asbinary(force_collection(force_2d(geom)),'NDR'),arealoc
ation.geometryid::text from (SELECT a.quid as quid, a.quname AS name,
a.color, b.geometrie AS geom FROM arealocation b LEFT JOIN all_qu a ON
b.geometryid = a.geometrie) as foo WHERE geom && setSRID('BOX3D(2516850
5658600,2542250 5684000)'::BOX3D, -1 )' <br><br>

Postgresql reports the error as 'ERROR:  column "id" does not exist

I wonder where this column "id" comes from?? 

I hope, that someone can help...

Thanks in advance,


Bjoern.



More information about the mapserver-users mailing list