<div dir="ltr">It didn't remember to ask "what version?".<div>Anyway I think the problem could be due to the sequence.</div><div>When you use a "serial" data type, you are asking to the database to create an integer column with a linked sequence. </div><div>When you create a view on the table, it does not know how to deal with the integer column. A rule or a trigger would inform the view about its desired behaviour, i. e. when you have no value for the primary key, just squeeze the sequence for a new one.</div><div>c</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 16, 2016 at 4:29 PM, Andrea Peri <span dir="ltr"><<a href="mailto:aperi2007@gmail.com" target="_blank">aperi2007@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Carlo.<br>
Thx for response.<br>
<br>
I 'm testing better.<br>
But the strange is that the first write was regulrly executed.<br>
If the view was really read-only it should refuse also the first write.<br>
<br>
Instead only from the second write I have the error.<br>
<br>
And the qgis don't report me a "readonly view.<br>
But instead a "id primary key cannot be nul" constraint violation.<br>
<br>
I try to understand better all of this.<br>
<br>
Regards,<br>
<br>
A.<br><br>
<br>
2016-11-16 15:54 GMT+01:00 Carlo A. Bertelli (Charta s.r.l.)<br>
<<a href="mailto:carlo.bertelli@gmail.com">carlo.bertelli@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Ciao Andrea,<br>
> by default Postgresql views are read only. Even the simplest view made in<br>
> Postgresql needs a rule to be updated. After writing a statement for a view,<br>
> just take the habit of writing the rules for insert, update, delete.<br>
> Please read the chapter on the Rule System in the Postgresql Reference<br>
> Manual for the instructions.<br>
> c<br>
><br>
> Message: 6<br>
> Date: Wed, 16 Nov 2016 09:39:23 +0100<br>
> From: Andrea Peri <<a href="mailto:aperi2007@gmail.com">aperi2007@gmail.com</a>><br>
> To: Matthias Kuhn <<a href="mailto:matthias@opengis.ch">matthias@opengis.ch</a>><br>
> Cc: qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><br>
> Subject: Re: [Qgis-user] Editing a Postgis view<br>
> Message-ID:<br>
>         <CABqTJk8Bo7fs6qOG=<wbr>MhO9N50qO5L+JkXAOAgik=<a href="mailto:tUGWwcKd-WA@mail.gmail.com">tUGWwcKd<wbr>-WA@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset=UTF-8<br>
><br>
> Hi Matthias,<br>
> thx for response.<br>
> So the trouble is in my db.<br>
><br>
> Now I try to understand better why it is not working.<br>
><br>
> This is my actual try test:<br>
><br>
> create table schemaapp.repository(<br>
>  ID serial primary key NOT NULL,<br>
>  UUID varchar(50) NOT NULL,<br>
>  PROGETTO varchar(9) NOT NULL,<br>
>  PROCEDIMENTO text NOT NULL,<br>
>  GEOMETRIA1 geometry(MULTIPOINT, 3003)<br>
> );<br>
><br>
> create view schemaapp.v_repository_point as<br>
>  select<br>
>   <a href="http://a.id" rel="noreferrer" target="_blank">a.id</a> as id,<br>
>   a.uuid as uuid,<br>
>   a.progetto as progetto,<br>
>   a.procedimento as procedimento,<br>
>   a.geometria1 as geometria<br>
> from<br>
>   schemappa.repository_wfs as a<br>
> where<br>
>   a.geometria1 is not null;<br>
><br>
> I will know if discover something.<br>
> thx again.<br>
><br>
> 2016-11-16 8:54 GMT+01:00 Matthias Kuhn <<a href="mailto:matthias@opengis.ch">matthias@opengis.ch</a>>:<br>
>> Hi Andrea,<br>
>><br>
>> It works here.<br>
>> Do you have an instead of insert rule written on your view?<br>
>> It works for me this way (but my views are too complicated for postgres<br>
>> to create default insert rules by default anyway).<br>
>> You can also try to alter your view with a default value for the column<br>
>> in question.<br>
>><br>
>> Best regards<br>
>> Matthias<br>
>><br>
>> On 11/16/2016 08:15 AM, Andrea Peri wrote:<br>
>>> Hi,<br>
>>> I'm having some trouble to edit a postgis view using qgis.<br>
>>><br>
>>> The view is a simple:<br>
>>> select list-of-field from table1;<br>
>>><br>
>>> And the table1 is a table with a Primary key on a serial type field.<br>
>>><br>
>>> I add the first record and all was ok. The commit too.<br>
>>> When go to add the second record.<br>
>>> I start to have trouble.<br>
>>> The qgis report my always a constraint violation of the pk.<br>
>>> I try to leave the pk field empty, or try to fill it with a value.<br>
>>> No solution work.<br>
>>><br>
>>> So my question is if is confirmed that qgis (I use the 2.18) version)<br>
>>> is working in editing with a postgis view .<br>
>>><br>
>>> Thx.<br>
>>> A.<br>
>>><br>
>>><br>
>>><br>
>> ______________________________<wbr>_________________<br>
>> Qgis-user mailing list<br>
>> <a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
>> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
>> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
> List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
> Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
-----------------<br>
Andrea Peri<br>
. . . . . . . . .<br>
qwerty àèìòù<br>
-----------------<br>
</font></span></blockquote></div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div></div></div>
</div></div></div>