create trigger
"DBA".xf_vipbonusadd_upd before update
on "dba".xf_vipbonusadd
referencing old as old_vipbonusadd new as new_vipbonusadd
for each row
begin
  if(new_vipbonusadd.xf_lastmoddate is null) or(new_vipbonusadd.xf_lastmoddate=old_vipbonusadd.xf_lastmoddate) then
    set new_vipbonusadd.xf_lastmoddate=now(*)
  end if
end

解决方案 »

  1.   

    D. Using deferred name resolution
    The following example creates two DML triggers to illustrate deferred name resolution.  Copy Code 
    USE AdventureWorks;
    GO
    IF OBJECT_ID ('HumanResources.trig1','TR') IS NOT NULL
       DROP TRIGGER HumanResources.trig1;
    GO
    -- Creating a trigger on a nonexistent table.
    CREATE TRIGGER HumanResources.trig1
    on HumanResources.Employee
    AFTER INSERT, UPDATE, DELETE
    AS 
       SELECT e.EmployeeID, e.BirthDate, x.info 
       FROM HumanResources.Employee AS e INNER JOIN does_not_exist AS x 
          ON e.EmployeeID = x.xID
    GO
    -- Here is the statement to actually see the text of the trigger.
    SELECT t.object_id, m.definition
    FROM sys.triggers AS t INNER JOIN sys.sql_modules AS m 
       ON t.object_id = m.object_id
    WHERE t.type = 'TR' and t.name = 'trig1'
    AND t.parent_class = 1
    GO-- Creating a trigger on an existing table, but with a nonexistent 
    -- column.
    USE AdventureWorks;
    GO
    IF OBJECT_ID ('HumanResources.trig2','TR') IS NOT NULL
       DROP TRIGGER HumanResources.trig2
    GO
    CREATE TRIGGER HumanResources.trig2 
    ON HumanResources.Employee
    AFTER INSERT, UPDATE
    AS 
       DECLARE @fax varchar(12)
       SELECT @fax = 'AltPhone'
       FROM HumanResources.Employee
    GO
    -- Here is the statement to actually see the text of the trigger.
    SELECT t.object_id, m.definition
    FROM sys.triggers AS t INNER JOIN sys.sql_modules AS m 
       ON t.object_id = m.object_id
    WHERE t.type = 'TR' and t.name = 'trig2'
    AND t.parent_class = 1
    GO