I\'m attempting to create a sql script that should check to see if a row exists. If one doesn\'t exist, I want to create one and if one does exist, I want to update it.
g4b_stockcountsummary is a view. Views can be updatable, but only under certain conditions. These are listed in the documentation and they start:
Updatable Views
You can modify the data of an underlying base table through a view, as long as the following conditions are true:
- Any modifications, including
UPDATE,INSERT, andDELETEstatements, must reference columns from only one base table.
Hence, you cannot do what you want. You either need to fix the view or update each base table independently.
I should point out that lad2025 is correct. You can use an instead of trigger on the view to support the update. The documentation is referring to the base update on the view.