<div dir="ltr">Hi Matthias,<div><br></div><div>thanks for your answer. Sorry but I missed your previous mail.</div><div>Now I've seen that in your example you used TRIGGERS to update your data, instead in my case I use view RULES.<br></div><div><div>I try to add "RETURNING new" clause in the rules but it doesn't work.</div></div><div><br></div><div>I can try to change all my code and substitute RULES with TRIGGERS but I still hope there is another way to maintain the possibility of using rules.</div><div>Is It possible that I'm just missing a simply solution because I don't know well the using of RETURNING in postgres views?</div><div><br></div><div>thanks</div><div>Luca</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-23 18:15 GMT+01:00 Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Luca,<br>
<br>
this was a deliberate change to allow QGIS to directly use the newly<br>
inserted features (e.g. add child records to a newly created feature).<br>
<br>
To make the views compatible with this, all you need to do is add a<br>
<br>
    RETURN NEW;<br>
<br>
to the end of the insert function (I think). Have a look at the views<br>
which I linked in my response in the other thread.<br>
<br>
We could possibly add a flag to specify in which cases we need the new<br>
primary key and in which cases not.<br>
But I somehow suspect, that in the end we will need to specify this in<br>
some often-used code (e.g. add feature form) and in the end one will<br>
still be required to update all views and we have some half-baked<br>
pointless workaround code inside QGIS.<br>
<br>
Hope that helps for you!<br>
Matthias<br>
<div><div class="h5"><br>
On 01/23/2017 04:19 PM, Luca Lanteri wrote:<br>
> Hi to all,<br>
><br>
> after a short disscussion in qgis user list I've opened this ticket [0],<br>
> because starting from QGIS 2.16 I can't insert new feature in postgres<br>
> views using rules. When I try to insert a new feature I have this error<br>
> [1]. All works fine with QGIS 2.14. The problem happens only with INSERT<br>
> rules. UPDATE and DELETE are ok.<br>
><br>
> I saw that for simple rules I can add a RETURNING * clause and all works<br>
> fine, but I have a lot of complex view that use many tables, so<br>
> RETURNING * clause doesn't work and compose the clause it's really hard.<br>
><br>
> Then I have some question:<br>
> 1) Is it really an issue or the problem is due to a new functionality of<br>
> QGIS ?<br>
> 2) In the first case, it could be considered a regression for it works<br>
> on QGIS 2.14 ?<br>
> 3) Is there a simple way to modify my views by adding a RETURNING clause<br>
> without specify all returning field (* doesn't work) ?<br>
><br>
> I love to know if it's a deliberate change or it's just a bug,so I can<br>
> choose if I have to modify all my views, in order to allow me to migrate<br>
> to QGIS 2.18.<br>
><br>
> Many thanks in advance<br>
> Regards<br>
> Luca<br>
><br>
><br>
> [0] <a href="https://hub.qgis.org/issues/16083" rel="noreferrer" target="_blank">https://hub.qgis.org/issues/<wbr>16083</a><br>
><br>
> [1] Impossibile applicare le modifiche al vettore v_frane_pol_full<br>
><br>
> Errori: ERRORE: 1 geometria non aggiunta.<br>
> Errori della sorgente dati:<br>
> Errore PostGIS nell'aggiunta delle geometrie: ERROR: cannot perform<br>
> INSERT RETURNING on relation "v_frane_pol_full"<br>
><br>
> HINT: You need an unconditional ON INSERT DO INSTEAD rule with a<br>
> RETURNING clause.<br>
><br>
><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> Qgis-developer mailing list<br>
> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
><br>
______________________________<wbr>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a></blockquote></div><br></div>