my dog learned polymorphism*
The moose likes JDBC and the fly likes one row trigger Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "one row trigger" Watch "one row trigger" New topic
Author

one row trigger

natx
Greenhorn

Joined: Aug 13, 2001
Posts: 4
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: one row trigger