[postgis-devel] How define a view that use a case operator for geometry field

Sandro Santilli strk at keybit.net
Fri Oct 28 11:21:31 PDT 2011


On Fri, Oct 28, 2011 at 07:11:18PM +0200, aperi2007 wrote:

> I try
> SELECT * FROM v_elemento_divisorio WHERE ST_SRID(geom) = 0;
> the result was an empty recordset.
> 
> (very strange for me)
> 
> After this I change (following your suggest) the view with:
> 
> ...
> case
>   when a.codlinea<>'' then b.geom::geometry(LINESTRING,3003)
>   else c.geom::geometry(LINESTRING,3003)
> end as geom
> ...
> 
> And it work ! (wow)
...
> why the first view don't give any error ?

I guess PostgreSQL can't assume the columns is
geometry(LINESTRING, 3003)
if one of the fields is possibly an unspecified
geometry() ?

See also \d theview, it should tell you the field type
including geometry type (typmod).

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-devel mailing list