File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one row trigger

 
natx
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could someone help me please?
Although the following triggers dont give me any syntax error. Every time a user inserts or updates a record, the region field in the member table is set to NULL.
This is the code:
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
DECLARE @userid integer, @country nvarchar
SELECT @userid = member.userid, @country = member.country
FROM inserted, member
IF @userid = member.userid
BEGIN
UPDATE [member]
SET region = Region.area
FROM Region
WHERE Region.country = member.country
END
------------------------------------
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
SELECT i.userid = m.userid
FROM inserted i, member m
IF i.userid = m.userid
BEGIN
UPDATE [member]
SET region = Region.area
FROM Region
WHERE Region.country = member.country
END
---------------------------------------
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
UPDATE [member]
SET member.region = Region.area
FROM
[member]
JOIN Region ON Region.country = member.country
JOIN inserted ON inserted.userid = member.userid
Thanks so much
natalia http://www.nataliaz.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic