1. Erik Segerdell
  2. Valentina Studio
  3. Wednesday, April 24 2019, 11:16 PM
  4.  Subscribe via email
I'd like to be able to edit data in a view shown in a form TableView. Right now it seems that a view can only be read-only. In the toy example in Screen Shot 1, the "Observations" view was set up with the following in a PostgreSQL database:


CREATE VIEW observations_for_plate AS
SELECT observation.observation_id AS "Observation ID",
observation.plate_id AS "Plate ID",
observation.date AS "Date",
observation.alive AS "Alive",
observation.dead AS "Dead",
observation.censor AS "Censor"
FROM observation
ORDER BY observation.plate_id, observation.date;


For example, I'd like to change the data in the Dead column in the third row to "2". I know this can be done with the SQL:

UPDATE observations_for_plate SET "Dead"=2 WHERE "Observation ID"=20000040;

But I'd like to be able to do the same thing using the form.

Further, it would be desirable to do the same thing but within a more complex view (Screen Shot 2) like the following:


CREATE VIEW observations_for_plate AS
SELECT observation.observation_id AS "Observation ID",
observation.plate_id AS "Plate ID",
observation.date AS "Date",
observation.alive AS "Alive",
observation.dead AS "Dead",
observation.censor AS "Censor",
tech.tech_name AS "Tech Name"
FROM observation
LEFT JOIN tech ON observation.tech_id=tech.tech_id
ORDER BY observation.plate_id, observation.date;


However, in Postgres it seems that the same UPDATE statement doesn't work when the view selects from more than one table, and that a trigger or rule needs to be set up to do an update. But it would be great to be able to use the form to edit/update the data in this circumstance.

Thanks!
Attachments (2)
Comment
There are no comments made yet.
Sergey Pashkov Accepted Answer
Hello Erik,

Yes, I think we can support these two cases.
In the second case it is necessary to generate an ordinary UPDATE for the source table of the view:

UPDATE observation SET dead=2 WHERE observation_id =20000040;

Right?
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Studio
  3. # 1
Erik Segerdell Accepted Answer
Yes, that's right.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Studio
  3. # 2
Sergey Pashkov Accepted Answer
Hello Erik,

This feature will be available in version 9.2.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Studio
  3. # 3
Sergey Pashkov Accepted Answer
Hello Erik,

A new version is available for download.
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Studio
  3. # 4
Erik Segerdell Accepted Answer
Thank you!
Comment
There are no comments made yet.
  1. more than a month ago
  2. Valentina Studio
  3. # 5
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.