I am trying to Update a View (vwSPOpp3) which references another view which references other base tables. The update statement I am using is below and uses a join from my view to another table.
This is the code i'm using
///////
UPDATE vwSPOpp3
SET
New_ProjectManagement = tblImportOpportunities.[Proj Man],
New_SupportContract = tblImportOpportunities.[Supp Contract],
New_Labour = tblImportOpportunities.Labour,
New_Parts = tblImportOpportunities.Parts,
New_3rdParty = tblImportOpportunities.[3rd Party],
EstimatedValue = tblImportOpportunities.[Revenue (in CRM)]
FROM
vwSPOpp3
JOIN tblImportOpportunities ON
vwSPOpp3.OwnerIdName = tblImportOpportunities.OwnerIdName
AND vwSPOpp3.CustomerIdName = tblImportOpportunities.CustomerIdName
AND vwSPOpp3.Name = tblImportOpportunities.Name
///////
The error message I get tells me I can't do an update as it references base tables:
"View or function 'vwSPOpp3' is not updatable because the modification affects multiple base tables."
Can someone confirm that I can use a Trigger to get around this problem and what I should put in the trigger. Is it an INSTEAD OF UPDATE trigger? and what code should I put in the trigger so my SQL statement will work.
Any help will be really appreciated.
Thanks!
This is the code i'm using
///////
UPDATE vwSPOpp3
SET
New_ProjectManagement = tblImportOpportunities.[Proj Man],
New_SupportContract = tblImportOpportunities.[Supp Contract],
New_Labour = tblImportOpportunities.Labour,
New_Parts = tblImportOpportunities.Parts,
New_3rdParty = tblImportOpportunities.[3rd Party],
EstimatedValue = tblImportOpportunities.[Revenue (in CRM)]
FROM
vwSPOpp3
JOIN tblImportOpportunities ON
vwSPOpp3.OwnerIdName = tblImportOpportunities.OwnerIdName
AND vwSPOpp3.CustomerIdName = tblImportOpportunities.CustomerIdName
AND vwSPOpp3.Name = tblImportOpportunities.Name
///////
The error message I get tells me I can't do an update as it references base tables:
"View or function 'vwSPOpp3' is not updatable because the modification affects multiple base tables."
Can someone confirm that I can use a Trigger to get around this problem and what I should put in the trigger. Is it an INSTEAD OF UPDATE trigger? and what code should I put in the trigger so my SQL statement will work.
Any help will be really appreciated.
Thanks!