Hi,

Yes, there is a way to do this.

First, you have to create a 'sequence'. But you only have to do this once. It 
won't really matter if several different tables are using the same sequence in 
your situation.

create sequence sq; -- You only have to do this once. You could also make a 
temporary sequence. create temporary...

CREATE VIEW my_view AS (SELECT 
nextval('sq'), -- this is the function to access the next number from your 
sequence.
St_Union(wkb_geometry) FROM my_subregions GROUP BY region_id);

aman


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of William 
Furnass
Sent: August 18, 2010 1:52 PM
To: PostGIS Users Discussion
Subject: [postgis-users] QGIS requires

Hi,

QGIS requires that all PostGIS tables/views have a numeric primary
key.  As a result I have had to create many temporary tables solely
for the purpose of viewing the results of queries when ideally I would
have liked to create views from the majority of my queries.  Does
anyone know if I can create on-the-fly a serial numeric column in
queries/views to save me having to create so many temporary tables?
It'd be grand if something like the following were possible:

CREATE VIEW my_view AS (SELECT numeric_id_generator(),
St_Union(wkb_geometry) FROM my_subregions GROUP BY region_id);

Cheers,

Will
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to