Subject Updateable view
Author mike_noordermeer
This is a simple problem but unfortunately I don't know how to do
it. Would someone please help? WOuld you also be able to suggest a
document on the internet I might be able to reference for future
problems. Thanks.

I have an updateable view ...

CREATE VIEW ATHLETEMENTORS(
COMPETITORNO,
STAKEHOLDERNO,
STAKEHOLDERNAME,
STAKEHOLDEREMAIL,
ISACTIVE,
OCCUPATIONNO)
AS
select COMPETITORMENTOR.COMPETITORNO,
COMPETITORMENTOR.STAKEHOLDERNO,
STAKEHOLDERS.STAKEHOLDERNAME,
STAKEHOLDERS.STAKEHOLDEREMAIL,
STAKEHOLDERS.ISACTIVE,
STAKEHOLDERS.OCCUPATIONNO
from COMPETITORMENTOR INNER JOIN
STAKEHOLDERS ON
COMPETITORMENTOR.STAKEHOLDERNO=STAKEHOLDERS.STAKEHOLDERNO;

and a 'before insert' trigger ...

AS
BEGIN
INSERT INTO STAKEHOLDERS
Values(New.STAKEHOLDERNO, New.STAKEHOLDERNAME,
New.STAKEHOLDEREMAIL, New.ISACTIVE, NEW.OCCUPATIONNO);
INSERT INTO COMPETITORMENTOR
Values(New.CompetitorNo, New.STAKEHOLDERNO);
END

In the 'before insert' trigger I would like to check whether the
stakeholder already exists in the STAKEHOLDERS table by doing a case-
insensitive check for the STAKEHOLDERNAME and STAKEHOLDEREMAIL. If
it already exists, then use its STAKEHOLDERNO for the insert into
the COMPETITORMENTOR table.

Thanks again for your time

Regards

Mike