The Postgres documentation says
Simple views are automatically updatable: the system will allow INSERT, UPDATE and DELETE statements to be used on the view in the same way as on a regular table.
It then lists a number of requirements. I believe that my view meets all these requirements, yet if I try and insert into that view, I get the error:
psql:C355A12.txt:1702: ERROR: cannot insert into a view
HINT: You need an unconditional ON INSERT DO INSTEAD rule.
The view I'm inserting into is defined as:
CREATE VIEW locationsView
AS SELECT lc_name, lc_min, lc_max, lc_sizeX, lc_sizeY
FROM locations;
This is the table definition:
CREATE TABLE locations(
lc_name LocationName NOT NULL,
lc_min LocationMin NOT NULL
DEFAULT 0,
lc_max LocationMax NOT NULL
DEFAULT 0,
lc_sizeX LocationSizeX NOT NULL,
lc_sizeY LocationSizeY NOT NULL,
PRIMARY KEY (lc_name)
);
Domains used are:
CREATE DOMAIN LocationName AS TEXT;
CREATE DOMAIN LocationMin AS INT;
CREATE DOMAIN LocationMax AS INT;
CREATE DOMAIN LocationSizeX As INT;
CREATE DOMAIN LocationSizeY As INT;
How do I obtain this "automatically updatable"ness described by the documentation?
I'm using Postgres version 9.3.4.
You're reading documentation for a newer version of the PostgreSQL server than what you're connecting to running (8.4).
Simply updatable view support was introduced in PostgreSQL 9.3. Your psql client is version 9.3, but that doesn't affect server-side features if connecting to an 8.4 server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With