September 27, 2002 at 6:28 am
Hello there,
I need make one trigger to validate the values inserted or updated in a table. Is There a special identify that references the column values on Triggers???
I want know if there´s something like :new or :old identifies in Oracle.
Thanks, so much!
!Otávio!
September 27, 2002 at 7:11 am
Use the virtual tables named "inserted" and "deleted" to examine the before and after values of columns within a trigger. See "inserted tables" or "deleted tables" in BOL for more information.
Jay Madren
September 27, 2002 at 8:40 am
Thanks,
But I want change the value of the column!!!
e.g.:
in Oracle
trigger....
if :new.Column is Null then begin
:new.Column := 'myValue'
end;
I need make the same in SQL Server... is It necessary make a update in the table using inserted table?
Thanks
September 27, 2002 at 11:59 am
On your INSERT, you can use a DEFAULT constraint to put a value in the column if no value is specified.
If you need to handle in a trigger to cover updates, you probably want to do something like this:
CREATE TRIGGER trig_iu_MyTrigger
ON MyTable
FOR INSERT, UPDATE
AS
UPDATE MyTable
SET MyColumn = 'myValue'
FROM MyTable MT
JOIN inserted i
ON MT.PKey = i.Pkey
WHERE i.MyColumn IS NULL
K. Brian Kelley
http://www.truthsolutions.com/
Author: Start to Finish Guide to SQL Server Performance Monitoring
http://www.netimpress.com/shop/product.asp?ProductID=NI-SQL1
K. Brian Kelley
@kbriankelley
September 30, 2002 at 10:21 am
hi,
you can use this syntax
CREATE TRIGGER InsteadTrigger on InsteadView
INSTEAD OF INSERT
AS
BEGIN
.
.
.
Antonio
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply