Question & Answer
Question
Can I perform an INSERT/ UPDATE / DELETE on a view?
Answer
Since a view is effectively a synonym for another Select statement, if you want to change the contents of a view via an INSERT, UPDATE, or DELETE statement, then the INSERT, UPDATE, or DELETE must be applied to the tables in the original SELECT.
For example, if the following view is defined:
- create view view_orders as select id,ord_no,order_date from orders;
then:
- insert into view_orders ......
- delete from view_orders .....
- update view_orders .....
will all result in the error message:
- ERROR: Cannot insert/delete/update from a view without an appropriate rule.
In order to actually perform the INSERT, UPDATE, DELETE you would run either:
- insert into orders...
- delete from orders...
- update orders...
[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Historical Number
NZ746210
Was this topic helpful?
Document Information
Modified date:
17 October 2019
UID
swg21571470