Hi! I am falling in love with web2py!!! But I had got a little problem when migrated to 2.9.11-stable+timestamp.2014.09.15.23.35.11. After submit INSERT-form, I had got an error: <class 'psycopg2.NotSupportedError'> cannot perform INSERT RETURNING on relation "table_view" HINT: You need an unconditional ON INSERT DO INSTEAD rule with a RETURNING clause. I use web2py+Postgresql. In summary of my little research I was surprised, that DAL construct INSERT-query with RETURNING. It's no problem while INSERT into TABLE, but not for VIEW "If you want to support RETURNING queries on the view, you need to make the rules include RETURNING clauses that compute the view rows. This is usually pretty trivial for views on a single table, but it's a bit tedious for join views <http://www.postgresql.org/docs/current/interactive/rules-update.html> " RETURNING from join view looks like this: ... RETURNING ins_table.id, ins_table.f1, ins_table.f2, (SELECT table1.f1 FROM table1 WHERE table1.id= ins_table.id), (SELECT table1.f2 FROM table1 WHERE table1.id= ins_table.id);
Keep in mind, that (SELECT table1.f1, table1.f2 FROM table1 WHERE table1.id= ins_table.id) - not works! i.e. оne field - one SELECT. RETURNING clause should include all fields from VIEW, order is important. I suggest following: include this error in exceptions, if it happens - use currval(id_sequence) to get ID of new record, i.e. something from earlier versions. With very best regards -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.