I need a trigger on insert
Example for insert trigger:
MasterIp studentstat stustatus2 Active_status
----------------------------- ---------- -------- -------------
5.46.200.1.462222.2.1.1.1.1.1 0 0 1
If i created a record with "5.46.200.1.462222.2.1.1.1.1.1.1" then i need the stustatus2,Active_status values inherited from parent i.e "5.46.200.1.462222.2.1.1.1.1.1"
INSERT INTO MyTable (MasterIp , status1,status2,Active_status)
VALUES ('5.46.200.1.462222.2.1.1.1.1.1.1',0,1,1);
Expected output should be:
MasterIp studentstat stustatus2 Active_status
----------------------------- ---------- -------- -------------
5.46.200.1.462222.2.1.1.1.1.1 1 0 1
5.46.200.1.462222.2.1.1.1.1.1.1 0 0 1
I need a trigger for update as well.
If the updated MasterIp has childrens, set studentstat = 1 and all the children of that MasterIp should be set to the same stustatus2 and Active_status values as the parent MasterIp.
Ex: for Update trigger:
MasterIp studentstat stustatus2 Active_status
----------------------------- ------- -------- -------------
5.46.200.1.462222.2.1.1.1.1.1 0 0 1
5.46.200.1.462222.2.1.1.1.1.1.1 0 0 0
update MyTable set stustatus2=1 where masterip ='5.46.200.1.462222.2.1.1.1.1.1'
Expected output:
MasterIp studentstat stustatus2 Active_status
----------------------------- ------- -------- -------------
5.46.200.1.462222.2.1.1.1.1.1 1 1 1
5.46.200.1.462222.2.1.1.1.1.1.1 0 1 1
Please let me know if i m not clear in my explanation
Thanks for your help in advance