Does the user need the view? Does the view need to exist after the user exits the application? If not, then you can use temporary tables (these can also be regarded as temporary geometry objects). You can also create temporary views too, but it all depends on what your app does and what the user needs from it. An other strategy is to create a temporary table when the app gets initialized:<div>

<br></div><div>create temp geo_table (id integer primary key, geocol geometry);</div><div>create index geo_table_geocol_idx on geo_table using gist(geotable);</div><div><br></div><div>Then whenever a user selects from source_geo_table, use:</div>

<div><br></div><div>truncate geo_table; -- in case there was a previous selection</div><div>insert into geo_table(id, geocol)</div><div>  select id, geocol from source_geo_table</div><div>  where st_intersects(geocol, $1);</div>

<div><br></div><div>After the connection is closed (or the transaction is otherwise lost), the table will no longer exist.</div><div><br></div><div>Most tables and views -- temporary or not -- behave the same to client applications (selecting, using functions, etc), so long as you have control from a low-level API to control how objects are created and used during the session.</div>

<div><br></div><div>-Mike</div><div><br></div><div><div class="gmail_quote">2010/5/24 郭家成 <span dir="ltr"><<a href="mailto:iron1103@gmail.com">iron1103@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div>Hey Mike, I made a mistake.</div>
<div> </div>
<div>I tried to create a function to create view, but Postgre still gave me that errmsg, "there is no parameter $1".</div>
<div> </div>
<div>I think there is only one solution in my case:<br>1. Create a table that only has one geometry column</div>
<div>2. Insert a geometry</div>
<div>3. Create View</div>
<div>4. Drop that table</div>
<div> </div>
<div>Do u have better idea?</div>
<div> </div>
<div>Thank you for your enthusiastic !<br><br></div>
<div class="gmail_quote">郭家成 <span dir="ltr"><<a href="mailto:iron1103@gmail.com" target="_blank">iron1103@gmail.com</a>></span> 於 2010年5月24日下午4:04 寫道:<div><div></div><div class="h5"><br>
<blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote">
<div>Thanks a lot, Mike !  That's a great hint.</div>
<div> </div>
<div>I made a windows application, that allow user to browse spatial tables, and create</div>
<div>a view by dragging a rectangle on my application.</div>
<div> </div>
<div>$1 is that rectangle made by user.</div>
<div> </div>
<div>Can I create a temporary geometric object ? How to do that ?<br><br></div>
<div class="gmail_quote">
<div>2010/5/24 Mike Toews <span dir="ltr"><<a href="mailto:mwtoews@gmail.com" target="_blank">mwtoews@gmail.com</a>></span><br></div>
<blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote"><br>
<div>
<div></div>
<div>
<div class="gmail_quote">2010/5/24 郭家成 <span dir="ltr"><<a href="mailto:iron1103@gmail.com" target="_blank">iron1103@gmail.com</a>></span> 
<div><br>
<blockquote style="border-left:#ccc 1px solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class="gmail_quote">
<div><span style="color:rgb(0,0,153)">So, everything works fine without "CREATE VIEW", weird.</span></div></blockquote>
<div><br></div></div>
<div>I should have seen that earlier .. views don't have parameters, so that is why test 1-4 don't work. Views need to have existing columns. What is $1 supposed to be? A geometry column from a different table, or the same table? If you needs are only temporary, then explore the uses of "select * into <b>temp </b>tt from ..." then use tt like any other table until you don't need it anymore in the transaction, then it disappears out of sight.</div>



<div><br></div><font color="#888888">
<div>-Mike</div></font></div><br></div></div>
<div>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>


<br></div></blockquote></div><br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br></div>