<font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2"><font face="Verdana, Arial, Helvetica, sans-serif">It would help to see how you used row_number and what field you put in it.</font><div style="font-family: Verdana, Arial, Helvetica, sans-serif;"><br></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif;">You could create row_number after the dumping</div><div><font face="Verdana, Arial, Helvetica, sans-serif">select row_number() OVER (ORDER BY path,st_x,st_y.......) AS id, *</font></div><div><font face="Verdana, Arial, Helvetica, sans-serif"> from </font></div><div><font face="Verdana, Arial, Helvetica, sans-serif">(select .</font><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8px;">ST_DumpPoints...</span><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12.8px;">.. from ...)</span></div><div><br><font color="#990099" style="font-family: Verdana, Arial, Helvetica, sans-serif;">-----"Qgis-user" <qgis-user-bounces@lists.osgeo.org> a écrit : -----</font><div class="iNotesHistory" style="font-family: Verdana, Arial, Helvetica, sans-serif; padding-left: 5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">A : Karl Magnus Jönsson <Karl-Magnus.Jonsson@kristianstad.se><br>De : Árni Geirsson <arni@alta.is><br>Envoyé par : "Qgis-user" <qgis-user-bounces@lists.osgeo.org><br>Date : 12/04/2017 07:13<br>Cc: "qgis-user@lists.osgeo.org" <qgis-user@lists.osgeo.org><br>Objet : Re: [Qgis-user] Unique IDs in a PostGIS view<br><br><div dir="ltr">Thanks for the suggestion Karl.<div>I have used row_number() also but in the case of dumping vertex points from a line, multiple points are created from each line feature and therefore, the row_number is repeated for all points on the same line.</div><div><br></div><div>Árni</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><font color="#000000">Árni Geirsson</font><br><span style="font-size: x-small;"><font color="#666666"><font color="#666666"><b>Alta ehf</b> // +354 582 5000 // +354 897 9549</font></font></span></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On 12 April 2017 at 09:45, Karl Magnus Jönsson <span dir="ltr"><<a href="mailto:Karl-Magnus.Jonsson@kristianstad.se" target="_blank">Karl-Magnus.Jonsson@kristianstad.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="SV" link="blue" vlink="purple">
<div class="m_-6758276434687743317WordSection1">
<p class="MsoNormal"><a name="m_-6758276434687743317_T_Default_Reply"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d">Hi!<u></u><u></u></font></span></a></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d">I’ve used something like this to get unique Ids:<u></u><u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d">SELECT row_number() OVER (ORDER BY s.omrade_id, s.kod) AS id, …. ORDER BY s.omrade_id, s.kod;<u></u><u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u> <u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d">If the ordering isn’t necessary I guess you can skip that.<u></u><u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u> <u></u></font></span></p>
<p class="MsoNormal"><a href="https://www.postgresql.org/docs/current/static/functions-window.html" target="_blank"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif"">https://www.postgresql.org/<wbr>docs/current/static/functions-<wbr>window.html</span></a><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u><u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u> <u></u></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u> <u></u></font></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";color:black">Karl-Magnus Jönsson</span></b><span style="font-size:10.0pt;font-family:"Franklin Gothic Book","sans-serif";color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size: 11pt; font-family: Calibri, sans-serif;"><font color="#1f497d"><u></u> <u></u></font></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Från:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Qgis-user [mailto:<a href="mailto:qgis-user-bounces@lists.osgeo.org" target="_blank">qgis-user-bounces@<wbr>lists.osgeo.org</a>]
<b>För </b>Árni Geirsson<br>
<b>Skickat:</b> den 12 april 2017 11:34<br>
<b>Till:</b> <a href="mailto:qgis-user@lists.osgeo.org" target="_blank">qgis-user@lists.osgeo.org</a><br>
<b>Ämne:</b> [Qgis-user] Unique IDs in a PostGIS view<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I am trying to create a view that extracts vertices from lines using ST_DumpPoints and to get unique IDs I have set up a sequence to generate the numbers using nextval(). The query executes normally in the DB Mananger and I see the results
as a table in the table view. However, when I attempt to load the results of the view as a layer in QGIS, I get an error: "Database error: ERROR: cannot execute nextval() in a read-only transaction". No features are loaded.<u></u><u></u></p>
<div>
<p class="MsoNormal">Are there any smart tricks out there to work around this or other means of generating the IDs?<u></u><u></u></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="color:black">Árni Geirsson</span><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span></div>
</div>
</blockquote></div><br></div>
<div><font face="Courier New,Courier,monospace" size="3">_______________________________________________<br>Qgis-user mailing list<br>Qgis-user@lists.osgeo.org<br>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></font></div></qgis-user-bounces@lists.osgeo.org></arni@alta.is></div></div></div><div><br>Si vous n'êtes pas le destinataire de ce message, veuillez le détruire près avoir informé l'expéditeur de son erreur. Par ailleurs, il est interdit de copier ou de modifier ce courriel sans l'autorisation de l'auteur.<br><br>L'Institut national de santé publique du Québec n'assume aucune responsabilité à l'égard du contenu des messages personnels envoyés par ses employés.<br></div></font>