Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

create insertion rule on view returning id

$
0
0

I have a table private.products and a view public.products representing that table. And I want to create entries in private.products while inserting into view, it all works right, except that I also what to return the inserted id:

CREATE RULE insert_product 
AS ON INSERT TO public.products DO INSTEAD 
INSERT INTO private.products (name) VALUES (new.name) RETURNING products.id;
ERROR:  RETURNING list has too few entries

What am I doing wrong?


Viewing all articles
Browse latest Browse all 1138

Trending Articles