create trigger tri_new_user
after insert on tb_user
for each row
update tb_company_stats set user_count = user_count + 1;
create table tb_company_stats(user_count int default 0)
insert into tb_company_stats values (0)
db2 => create trigger tri_new_user
db2 (cont.) => after insert on tb_user
db2 (cont.) => for each row
db2 (cont.) => update tb_company_stats set user_count = user_count + 1
db2 (cont.) => @
DB20000I The SQL command completed successfully.
create trigger tri_delete_user
after delete on tb_user
for each row
update tb_company_stats set user_count = user_count - 1
db2 => create trigger tri_delete_user
db2 (cont.) => after delete on tb_user
db2 (cont.) => for each row
db2 (cont.) => update tb_company_stats set user_count = user_count - 1
db2 (cont.) => @
DB20000I The SQL command completed successfully.