I think the QGis code should not have this specific behaviour and should follow the standards.<br><br>If the key doesn't contain any informations and is just a number, then OK we  can explicitly tell QGis to use a PostgreSQL sequence to create this arbitrary number.<br>
In my case, the values of the key come from an other application and I have to type these values to link the geometrical objects to the database informations.<br><br>I found a workaround : if I change the field type of the key from integer to bigint then everything works as attended...<br>
QGis doesnt tries anymore to give a value when we don't need it.<br>But this is not very logical isn't it?<br><br>Fabrice<br><br><br><div class="gmail_quote">2012/5/15 Bernhard Ströbl <span dir="ltr"><<a href="mailto:bernhard.stroebl@jena.de" target="_blank">bernhard.stroebl@jena.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Fabrice,<br>
<br>
I think this is the intended behaviour. If you leave it to the user to enter the primary key then the db might complain about non-unique keys. On the other hand why would you _want_ to assign a certain key? A key is just a technical field used to identify a dataset. It should not contain any information.<br>

On my db I have three tables (point, line, polygon) that insert into the same table representing a n:m relation. I use a sequence on the db and a trigger to assign the next sequence value on INSERT. Apart from that I have no need to interfere with my pk values and I am glad, that QGIS takes care of that.<br>

<br>
Bernhard<br>
<br>
Am 15.05.2012 13:07, schrieb F T:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
Hi all,<br>
<br>
We are not able to set explicitly the value of an integer primary key field.<br>
<br>
It is possible to set this value with pgAdmin.<br>
But when the feature is created with QGis, it takes the next max value<br>
of the field and not the spécified value...<br>
<br>
To reproduce this strange behaviour :<br>
<br>
-- create a table in the schema public with an integer primary key<br>
CREATE TABLE the_table<br>
(<br>
   the_key integer NOT NULL,<br>
   the_obs character varying(150),<br>
   geom geometry,<br>
   CONSTRAINT the_table_pkey PRIMARY KEY (the_key),<br>
   CONSTRAINT enforce_dims_geom CHECK (st_ndims(geom) = 2),<br>
   CONSTRAINT enforce_geotype_geom CHECK (geometrytype(geom) =<br>
'MULTILINESTRING'::text OR geom IS NULL),<br>
   CONSTRAINT enforce_srid_geom CHECK (st_srid(geom) = 2154)<br>
)<br>
WITH (<br>
   OIDS=TRUE<br>
);<br>
-- spatialize the table<br>
INSERT INTO geometry_columns(f_table_<u></u>catalog, f_table_schema,<br>
f_table_name, f_geometry_column, coord_dimension, srid, "type")<br>
VALUES('', 'public', 'the_table', 'geom', 2, 2154, 'MULTILINESTRING');<br>
<br>
Then in QGIS :<br>
- add this table to a project<br>
- create 1 line with the_key=100 and save the edition -> open the<br>
attribute table and you see the_key=0<br>
- create 1 line with the_key=102 and save the edition -> open the<br>
attribute table and you see the_key=1<br>
<br>
If I modify the value of the_key in pgAdmin, by example put the value<br>
1000 instead of 1, then the next line created with QGis will have the<br>
value 1001.<br>
<br>
Any help is welcome !<br>
Thanks<br>
<br>
Fabrice<br>
<br>
<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-user</a><br>
<br>
<br>
</blockquote>
<br>
<br>
________ Information from NOD32 ________<br>
This message was checked by NOD32 Antivirus System for Linux Mail Server.<br>
<a href="http://www.nod32.com" target="_blank">http://www.nod32.com</a><br>
</blockquote></div><br>