<div dir="ltr">so, what was the answer?<br></div><div class="gmail_extra"><br clear="all"><div><div>--</div><div><a href="http://FarmBillPrimer.org" target="_blank">http://FarmBillPrimer.org</a></div><a href="http://www.BaltimoreUrbanAg.org" target="_blank">http://www.BaltimoreUrbanAg.org</a> (Please send events; This site is hungry.)<br>

<a href="http://www.ExcellentNutrition.org" target="_blank">http://www.ExcellentNutrition.org</a><br><a href="http://www.packtpub.com/drupal-5-views-recipes/book" target="_blank">http://www.packtpub.com/drupal-5-views-recipes/book</a><br>

</div>
<br><br><div class="gmail_quote">On Sat, Oct 12, 2013 at 1:37 PM, Peter Brown <span dir="ltr"><<a href="mailto:peterbrown.kew@gmail.com" target="_blank">peterbrown.kew@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Dear Alexandre<div>Sorry I have not replied before, but your suggestions have set me off on a new voyage of discovery. It has been exceeding helpful, so thank you very much</div><div>Regards</div><span class="HOEnZb"><font color="#888888"><div>

Peter</div>
</font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 7 October 2013 16:33, Alexandre Neto <span dir="ltr"><<a href="mailto:senhor.neto@gmail.com" target="_blank">senhor.neto@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Peter,<div><br></div><div>I'm not a database expert whatsoever, and there are better people in this list to clarify this. I just stated my experience with it.</div>


<div><br></div><div>As far as I know, in order to respect Postgres Primary keys, QGIS uses the columns default values.</div>
<div><br></div><div>If during the table creation your primary keys were created with something like: </div><div><br></div><div>CREATE TABLE <span style="font-family:arial,sans-serif;font-size:13px">yourtable</span></div>


<div>
(</div><div>gid serial NOT NULL,</div><div>...</div><div>)</div><div><br></div><div>Then, a sequence '<span style="font-family:arial,sans-serif;font-size:13px">yourtable_gid_seq'</span> is created and the default value for your gid column is set to <span style="font-size:13px;font-family:arial,sans-serif">nextval('yourtable_gid_seq'::</span><span style="font-size:13px;font-family:arial,sans-serif">regclass)</span></div>



<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">When a new feature(row) is created if the user does not fill the pk field (and he is not supposed to), postgres will consider the default value, give it the next not use value from the sequence and update the sequence.</span></div>



<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">If you are using QGIS, when you create a new feature or simply split an existing features, make sure not to type anything in the PK field, or this will give you a bad time. Just leave it blank, during the save\commit, both QGIS and Postgres will know what do do with it.</span></div>



<div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Not sure where all this knowledge came from, but have a look here:</span></div>



<div><a href="http://www.postgresql.org/docs/9.1/static/functions-sequence.html" target="_blank">http://www.postgresql.org/docs/9.1/static/functions-sequence.html</a><span style="font-size:13px;font-family:arial,sans-serif"><br>


</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Best regards,</span></div><div>Alexandre Neto</div></div><div>
<div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 3:59 PM, Peter Brown <span dir="ltr"><<a href="mailto:peterbrown.kew@gmail.com" target="_blank">peterbrown.kew@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="ltr">uummmm<div>Reading your answer {particularly the bit about <span style="font-size:13px;font-family:arial,sans-serif"> a nextval('yourtable_gid_seq'::</span><span style="font-size:13px;font-family:arial,sans-serif">regclass),}</span> I realise that this bit of code is an area of knowledge that I am missing, and clearly if it will solve my problem then it would be useful. I wonder if I could ask you to at least point me in the right direction.</div>




<div>I am fairly new to QGIS but generally a power user of databases, so I have read the excellent manual</div><div><a href="http://workshops.opengeo.org/postgis-intro/creating_db.html" style="font-size:11pt" target="_blank">http://workshops.opengeo.org/postgis-intro/creating_db.html</a></div>




<div>and the more fundamental one at </div><div><a href="http://www.postgresql.org/docs/9.2/interactive/sql.html" style="font-size:11pt" target="_blank">http://www.postgresql.org/docs/9.2/interactive/sql.html</a> </div><div>



However, I do not seem to have come across anything like this. Can you advise me?</div>
<div>Thank you for your help</div><div>Regards</div><span><font color="#888888"><div>Peter Brown</div></font></span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 7 October 2013 11:09, Alexandre Neto <span dir="ltr"><<a href="mailto:senhor.neto@gmail.com" target="_blank">senhor.neto@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I'm not sure If I followed your question, but in my experience with QGIS editing Postgres\postgis spatial tables, I add some smal hickups, but never with splitting.</div>




<div><br>
</div><div>If its a normal polygon and you wish to split it with a line, QGIS will assign to all your new polygons a nextval('yourtable_gid_seq'::regclass), and this should solve the PK's problem.</div><div><br>





</div><div>If it's a multipart polygon that you want to spit it's parts, you can use the multipartsplit plugin, and it will also take care of your primary keys.</div><div><br></div><div>Maybe it's a problem with your table, please send the creation SQL command and maybe someone can have a clue of what is happening.</div>





<div><br></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 10:41 AM, Peter Brown <span dir="ltr"><<a href="mailto:peterbrown.kew@gmail.com" target="_blank">peterbrown.kew@gmail.com</a>></span> wrote:<br>





<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for your prompt response, it is nice to know that it is possible, but the methods you remember do seem to have problems. <div>





- in QGIS I can split a polygon which is on a layer, and under the 'layer' option on the menu, I call up the attributes table, but that only offers me all the fields in the base PostGIS table EXCEPT   (a) the  ID and (b) the geometry</div>






<div>- I have tried manufacturing another PostGIS table with all the attributes of the polygon except an ID field with all its 'NO NULLS' etc, but then when I open a layer in QGIS it draws the polygon but shows it as not editable</div>






<div>You have obviously managed something clever, but I am not quite sure what</div><div>Regards</div><div>Peter Brown</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On 7 October 2013 09:32, Hugues François <span dir="ltr"><<a href="mailto:hugues.francois@irstea.fr" target="_blank">hugues.francois@irstea.fr</a>></span> wrote:<br>






</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><u></u>



<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>Hello,</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>I previously edited polygons from postgis within 
qgis and with no problem. If I remember well, before saving I also filled 
attribute data to give a new ID. Maybe if you just want to edit polygons without 
changing attributes, you may remove constraints on your postgis table 
(especially, uniques, not null and primary key) before editing (and then put the 
things right back to postgis).</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>Hugues.</span></font></div>
<div> </div>
<div align="left"> </div><br>
<div dir="ltr" align="left" lang="fr">
<hr>
<font face="Tahoma"><b>From:</b> <a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a> 
[mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Peter 
Brown<br><b>Sent:</b> Monday, October 07, 2013 9:53 AM<br><b>To:</b> 
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><b>Subject:</b> [postgis-users] Saving a split 
polygon<br></font><br></div><div><div>
<div></div>
<div dir="ltr">In Quantum GIS (QGIS) there is a very useful facility for taking a 
polygon in a PostGIS database linked to QGIS and splitting it. HOWEVER, when one 
then tries to save the two portions, PostGIS puts up an error message that it 
cannot save the new portion because it does not have a new ID (it can save the 
existing portion, because this is only an edit of an existing ID). 
<div>There are workarounds for this (e.g. convert to 'Shape' files) but they 
seem incredibly clumsy. Does anyone have a more direct solution?</div>
<div>Thanks</div>
<div>Peter Brown<br>
<div> </div></div></div></div></div></div>
<br></div></div>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>