mysql - Cursor inside trigger and updating the table column -


i have 3 tables

one userdetails columns user_id,user_name,name , lastmodifieddate. second role columns roleid,rolename , third table user_role columns user_id(foreign key referencing userdetails) , role_id (foreign key referencing role).

now thing whenever update or delete operation happens in role table need update column lastmodifieddate of userdetails table getting respective mapped user_id user_role table.

for example, have roleid 1,2,3,4 in role table , roleid '3' mapped user_id 101,102,103,104 in user_role table. if roleid '3' updated in role table need mapped userid user_role , update lastmodifieddate column sysdate.

i have use trigger, how don't know newbie in db , have no knowledge on it...please guys , have in mysql

you can create trigger this:

 create or replace trigger pt_ad_role after delete or update on role_table each row       begin         update user_table set lastmodifiedtime=current_timestamp() user_table u,role_table r,user_role  ur r.role_id=ur.role_id , ur.user_id=u.user_id , r.role_id=:old.role_id;     end  ; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -