[postgis-users] Create View with PostGis table

OpenGis opengis at libero.it
Thu Nov 13 08:47:38 PST 2003

Thanks every one!
CREATE VIEW only_pg_land_use AS SELECT t0.oid, t0.* FROM landusea_region t0;
Work fine!

>My landusea_region table:
>Field		Type
>gid 		int4 
>polygon_id 	int8 
>name 		varchar 
>langcode 	varchar 
>type 		varchar 
>city 		varchar 
>the_geom 	geometry
But it's not enough!
I found another trouble next step:
I try to perform view with a condition like:
test=> CREATE VIEW v_pG_w AS SELECT t0.oid, t0.* FROM landusea_region t0 
where gid < 10;
test=> CREATE VIEW v_land_t AS SELECT t0.oid, t0.*, num_pop FROM 
landusea_region t0, tab_zu where t0.name= tab_zu.nm;

-- both run OK in psql & in phpPgAdmin

Instead doesn't work with this mapfile:
    NAME LandUseA_region
#    DATA LandUseA_region                               # original shape 
file -- work fine
    CONNECTION "user=pg_user password=pg_passwd dbname=test host=linux_box"
#    DATA "the_geom from landusea_region"        # OK (table from shp2pgsql)
#    DATA "the_geom from only_pg_land_use"     # OK (view from previous 
tab with oid column) [1]
    DATA "the_geom from v_pg_w"                      # NO ERROR NO 
#    DATA "the_geom from v_land_t"                   # NO ERROR NO 

When I run mapserver I've map with all layer less LandUseA_region layer
and It's very strange there isn't any error!?

It's a big problem because only in [2] I can use FILTER in mapfile, but 
in [3] I need to perform where condition before mapfile in order to 
obtain data from another table.

I think that where condition lose geometry data type. It's right? How 
can resolve [3]?

Have you any advice?

Thanks in advance

opengis (at) libero (dot) it
AOL: open2gis

More information about the postgis-users mailing list