<p><span style="background-color: rgb(255, 255, 51);">ERROR:&nbsp; duplicate key violates unique constraint &quot;roadl_edges_source_key&quot;&nbsp; <br></span></p><p><br><span style="background-color: rgb(255, 255, 51);"></span></p>
<p><span style="background-color: rgb(255, 255, 51);">This occurs because of duplicate edges in the graph. <br></span></p><p><br><span style="background-color: rgb(255, 255, 51);"></span></p><p><span style="background-color: rgb(255, 255, 51);">
So you do the following to clean it up.<br></span></p><p>The following lines are taken from <a href="http://www.cartoweb.org/doc/cw3.3/xhtml/user.install.html">http://www.cartoweb.org/doc/cw3.3/xhtml/user.install.html</a>
<br></p><p>
            But if the data quality is poor, you need to delete the duplicates edges (they have the same
            source-target pairs of vertices).
            For example, to check that you have duplicated edges, you can type:
            </p>
                <pre class="screen">$ SELECT * FROM (SELECT source_id, target_id, count(*) AS c FROM roads_europe group by <br>source_id, target_id order by c)<br>AS foo where foo.c = 2;</pre>
                <p>
            If there is duplicated edges, to delete one of two rows, you can type: 
            </p>
                <pre class="screen">$ CREATE TABLE doublons AS SELECT * FROM roads_europe WHERE gid  in<br>(SELECT gid FROM (SELECT DISTINCT on (source_id, target_id) source_id, gid <br>FROM roads_europe) AS doublon);<br>
$ DELETE FROM roads_europe;<br>$ INSERT INTO roads_europe (SELECT * FROM doublons);<br>$ DROP TABLE doublons;</pre>Hope it helps.<br><br>Pradeep B V<br><a href="http://mapunity.org">http://mapunity.org</a><br><br><div><span class="gmail_quote">
On 12/16/06, <b class="gmail_sendername">Sasanka Gandavarapu</b> &lt;<a href="mailto:horryglory@gmail.com">horryglory@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all<br>
<br>
While using the Create_graph_tables function for integrating pgdijkstra with postgreSQL i am encountering the following error:<br>
I am directly using the demo datafiles(from cartoweb, hence i dont think there&nbsp; is any problem with the data). <br>
Also, before doing this, i created source and target fields in the
database by adding three new columns and using assign_vertex_id.<br>
<br>
can someone help, please...<br>
<br>
NOTICE:&nbsp; CREATE TABLE will create implicit sequence &quot;roadl_vertices_id_seq&quot; for serial column &quot;roadl_vertices.id&quot;<br>
CONTEXT:&nbsp; SQL statement &quot;CREATE TABLE roadl_vertices (id serial, geom_id int4&nbsp; NOT NULL UNIQUE)&quot;<br>
PL/pgSQL function &quot;create_graph_tables&quot; line 11 at execute statement<br>
<br>
NOTICE:&nbsp; CREATE TABLE / UNIQUE will create implicit index &quot;roadl_vertices_geom_id_key&quot; for table &quot;roadl_vertices&quot;<br>
CONTEXT:&nbsp; SQL statement &quot;CREATE TABLE roadl_vertices (id serial, geom_id int4&nbsp; NOT NULL UNIQUE)&quot;<br>
PL/pgSQL function &quot;create_graph_tables&quot; line 11 at execute statement<br>
<br>
NOTICE:&nbsp; CREATE TABLE will create implicit sequence &quot;roadl_edges_id_seq&quot; for serial column &quot;roadl_edges.id&quot;<br>
CONTEXT:&nbsp; SQL statement &quot;CREATE TABLE roadl_edges (id serial,
source int, target int, cost float8, reverse_cost float8, UNIQUE
(source, target))&quot;<br>
PL/pgSQL function &quot;create_graph_tables&quot; line 15 at execute statement<br>
<br>
NOTICE:&nbsp; CREATE TABLE / UNIQUE will create implicit index &quot;roadl_edges_source_key&quot; for table &quot;roadl_edges&quot;<br>
CONTEXT:&nbsp; SQL statement &quot;CREATE TABLE roadl_edges (id serial,
source int, target int, cost float8, reverse_cost float8, UNIQUE
(source, target))&quot;<br>
PL/pgSQL function &quot;create_graph_tables&quot; line 15 at execute statement<br>
<br style="background-color: rgb(255, 255, 51);">
<span style="background-color: rgb(255, 255, 51);">ERROR:&nbsp; duplicate key violates unique constraint &quot;roadl_edges_source_key&quot;&nbsp; </span><br>
CONTEXT:&nbsp; SQL statement &quot;INSERT INTO roadl_edges (id, source, target) VALUES (91, '107', '109')&quot;<br>
PL/pgSQL function &quot;create_graph_tables&quot; line 27 at execute statement<br>
<br>
Thanks in advance,<br>
Horry<br>

<br>_______________________________________________<br>postgis-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br><br>
<br></blockquote></div><br>