Hello Lee, I'm glad it's "trying" to help you.<br><br>Yes, the function looks for the PK of each table, when you try yo enable it.<br><br>I'm at work right now, but an easy way to do it would be creating a function which accepts the primary key field as a parameter, which was the original design. I'll see if I can find an old version for it and I'll mail it to you.<br>

<br>Furthermore, I'll try to fix this bug. Thanks for catching it.<br><br>Any other questions you might have, just drop me a line.<br><br>George<br><br><div class="gmail_quote">On Tue, Aug 3, 2010 at 4:02 PM, Lee <span dir="ltr"><<a href="mailto:quimby5@yahoo.com" target="_blank">quimby5@yahoo.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div style="font-family: bookman old style,new york,times,serif; font-size: 10pt;">For sure! I was just about to sit down this week and write something very similar.<br>


<br>I grabbed it from SVN and trying to make it work on postgres8.4/postgis1.4.   I got as far as select postgis_enable_history(schema,table,geom) but get the following error:<br><br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">ERROR:  more than one row returned by a subquery used as an expression</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">


<span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">CONTEXT:  SQL statement "SELECT  (SELECT column_name FROM information_schema.key_column_usage WHERE table_schema =  $1  AND
 table_name =  $2 )"</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);"><span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">PL/pgSQL function "postgis_enable_history" line 31 at assignment</span><br>


<br><br>I think maybe it doesn't account for tables with foreign keys??  As a test, I tried this:<br><br><span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">select * from information_schema.key_column_usage where table_schema='base' and table_name = 'wtr_mainvalves'</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">


<span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">"midlandgis_test";"base";"mainvalves_pkey";"midlandgis_test";"base";"wtr_mainvalves";"gid";1;</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">


<span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">"midlandgis_test";"base";"mainvalves_owner_fkey";"midlandgis_test";"base";"wtr_mainvalves";"owner";1;1</span><br style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">


<span style="font-family: Courier New,courier,monaco,monospace,sans-serif; color: rgb(67, 67, 67);">"midlandgis_test";"base";"mainvalves_status_fkey";"midlandgis_test";"base";"wtr_mainvalves";"status";1;1</span><br style="color: rgb(67, 67, 67);">


<br>Furthermore, I tried enabling another table with no foreign keys - no problem there.  <br><br>Looking into the function code, it appears to be looking for a primary key to use in the history table, but I can't immediately see an easy way to differentiate between a pk and fk in the key_column table.<br>


<div><br>Anyone have any ideas?
 <br></div><br>Lee<br><div><br></div><div style="font-family: bookman old style,new york,times,serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1">


<b><span style="font-weight: bold;">From:</span></b> Rick <<a href="mailto:graham.rick@gmail.com" target="_blank">graham.rick@gmail.com</a>><br><b><span style="font-weight: bold;">To:</span></b> PostGIS Users Discussion <<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a>><br>


<b><span style="font-weight: bold;">Sent:</span></b> Tue, August 3, 2010 12:42:05 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [postgis-users] How to setup a versioned datastore?<br></font><div><div>

</div>
<div><br>
<div class="gmail_quote">On Tue, Aug 3, 2010 at 12:17 PM, George Silva <span dir="ltr"><<a rel="nofollow" href="mailto:georger.silva@gmail.com" target="_blank">georger.silva@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">



Hello Mark,<br><br>Check the SVN<br><br><span><a href="http://svn.osgeo.org/postgis/tags/1.5.1/extras/history_table/" target="_blank">http://svn.osgeo.org/postgis/tags/1.5.1/extras/history_table/</a></span><div><div></div>


<div>
<br></div></div></blockquote></div><br>Wow!  This looks like just the thing for me.<br><br>Thanks George.<br><br>-- <br>Cheers!<br>Rick<br>
</div></div></div></div>
</div></div><br>_______________________________________________<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></blockquote></div><br><br clear="all"><br>-- <br>George R. C. Silva<br><br>Desenvolvimento em GIS<br><a href="http://blog.geoprocessamento.net" target="_blank">http://blog.geoprocessamento.net</a><br>