I have an 'instead of update trigger' for a view. I would like to call a stored procedure from this view. I put the code into the trigger, I know the procedure works, Ive tested/executed it. But the trigger doesn't execute it. Here is what the update kind of looks like...
ALTER TRIGGER InsUpTrg_vwPIWDB on dbo.[PIW DB]
INSTEAD OF Update
AS
BEGIN
UPDATE dbo.[tblPIW_DB1] SET
[Address] = i.[Address],
.....
from inserted i
WHERE dbo.[tblPIW_DB1].[prop_num] = i.[prop_num]
UPDATE dbo.[tblPIW_DB2] SET
[Payment Term] = i.[Payment Term],
.....
from inserted i
WHERE dbo.[tblPIW_DB2].[prop_num] = i.[prop_num]
--here is the stored procedure call
declare @prop_num int
select @prop_num=i.[prop_num] from inserted i
exec pCalcFinancial @prop_num
I have tried applying this procedure call on the two tables that are in the view individually. It works but if the user updates fields that are in both table 1 and table 2 they get an error stating the record is being updated.
ALTER TRIGGER InsUpTrg_vwPIWDB on dbo.[PIW DB]
INSTEAD OF Update
AS
BEGIN
UPDATE dbo.[tblPIW_DB1] SET
[Address] = i.[Address],
.....
from inserted i
WHERE dbo.[tblPIW_DB1].[prop_num] = i.[prop_num]
UPDATE dbo.[tblPIW_DB2] SET
[Payment Term] = i.[Payment Term],
.....
from inserted i
WHERE dbo.[tblPIW_DB2].[prop_num] = i.[prop_num]
--here is the stored procedure call
declare @prop_num int
select @prop_num=i.[prop_num] from inserted i
exec pCalcFinancial @prop_num
I have tried applying this procedure call on the two tables that are in the view individually. It works but if the user updates fields that are in both table 1 and table 2 they get an error stating the record is being updated.