Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL MySQL
Hello friends,
I am creating Trigger in MYSQL and I got some error there its work well in MS-SQL.
Please tell me my error.
 
\\code
delimiter //
Create Trigger trgAfterUpdate AFTER UPDATE ON incident FOR EACH ROW
begin
 declare item_id varchar(20);
 declare subject varchar(100) ;
 declare work_flow varchar(20) ;
 declare team_member varchar(20) ;
 declare types_of_graphics varchar(20) ;
 declare department varchar(30) ;
 declare graphics_type varchar(30) ;
 declare item_mode varchar(30) ;
 declare in_time varchar(20) ;
 declare out_time datetime ;
 declare status varchar(20) ;
 declare priority varchar(20) ;
 declare description longtext ;
 declare Audit_Action varchar(100) ;
 declare Audit_Timestamp datetime ;
 set item_id = new.item_id;
 set subject = new.subject;
 set work_flow = new.work_flow;
 set team_member = new.team_member;
 set types_of_graphics = new.types_of_graphics;
 set graphics_type = new.graphics_type;
 set item_mode = new.item_mode;
 set out_time = new.out_time;
 set status = new.status;
 set priority = new.priority;
 set description = new.description;
 set audit_action='Updated Record -- After Update Trigger.';
 
IF UPDATE(work_flow)
        THEN  @audit_action = 'Updated work_flow -- After Update Trigger.';
    ELSEIF update(team_member)
        Then set @audit_action='Updated team_member -- After Update Trigger.';
            Else update(status)
         set @audit_action='Updated status -- After Update Trigger.';
 
 End IF
 
  INSERT INTO incident_audit (item_id, subject, work_flow, team_member, types_of_graphics, department, graphics_type, item_mode, in_time, out_time, status, priority, description, Audit_Action, Audit_Timestamp) VALUES (item_id, subject, work_flow, team_member, types_of_graphics, department, graphics_type, item_mode, in_time, out_time, status, priority, description, Audit_Action, sysdate());
 END
Posted 30-Mar-13 0:05am
Edited 10-Apr-13 1:13am
v3
Comments
Neetesh Agarwal at 30-Mar-13 5:07am
   
I got Problem in Update Block......... IF UPDATE(work_flow)
Tadit Dash at 10-Apr-13 7:02am
   
What is the error or exception ?
CHill60 at 10-Apr-13 6:34am
   
What is the error?
Neetesh Agarwal at 10-Apr-13 7:07am
   
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE(work_flow)
THEN @audit_action = 'Updated work_flow -- After Update' at line 30
Neetesh Agarwal at 10-Apr-13 7:07am
   
Which function I can use here Instead of Update ?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You will need to programmatically check for NEW.col1 <=> OLD.col1
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 341
1 Marcin Kozub 225
2 Praneet Nadkar 197
3 Sergey Alexandrovich Kryukov 190
4 Shweta N Mishra 161
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 3 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100