How to write trigger in oracle to check for one specific condiition -


i have 1 table name user_count_details. there total 3 columns in table.

  1. msisdn=which uniquely defines row 1 specific user
  2. user_count= stores count of user.
  3. last_txn_id= stores last transfer id of txn user has performed.

the user_count column of table user_count_details gets updated every transaction performed user.

but here logic of system

select sum(user_count ) user_count_details 

will gives 0 , considered system in stable state , fine.

now want write trigger check first when new request update user_count come ,will hamper sum(user_count )=0 or not , if hampers msisdn details captured in separate update table.

based on last comments, check if works. replace other_table_name per scenario.

create trigger trgcheck_user_sum   before insert      on user_count_details each row   begin             if (select sum(user_count) user_count_details) > 0           insert other_table_name(msisdn) values(new.msisdn)       end if end 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -