Dec 16, 2010

UpdateTriggers example

update Trigger
delimiter//
create TRIGGER v57node_update before update ON v57node
FOR EACH ROW
BEGIN  
IF NEW.uuid  is null THEN
     SET NEW.uuid =unhex(REPLACE(UUID(),'-',''));
         END IF;
set @masteruuid=(select masterUUid from v20ucr_session_lookup where ucr_session_id=new.ucr_session_id);
set @masterTable=(select masterTable from v20ucr_session_lookup where ucr_session_id=new.ucr_session_id);
if@masteruuid is not null then
insert into v20ucr_record_master(tableName,recUUID,clientMask,masterUUID,ucr_session_id,masterTable)
values('v57node',new.uuid, new.clientmask,@masteruuid,new.ucr_session_id,@masterTable);
end if;
END;

No comments:

Post a Comment