Stored procedure
Posted in 1999
I want to create a trigger which will insert a row in same table when a column holds certain value initially once only. If the column holds the same value when new row is inserted , the trigger should NOT insert a row in the same table. e.g. Insertion on table sfp_prebd with fund_code = '999' should insert a row in same table for the first time, but if again I get fund_code '999' it should not insert a row when the event occurs second time. Here is the trigger I've written. Can somebody help me achieve the same - create trigger "db".gstrg_1 insert on sfp_prebd referencing new as new_ins for each row when (new_ins.fund_code = '999' ) (insert into sfp_prebd ( trans_date , login_id , new_app_prg_code , dist_code integer, new_app_attend , new_app_project , doc_trans_date , trans_type , trans_seq , release_seq , fund_code , subfund_code , doc_total , match_50_50 , site_acq , sdc_non_sev , sdc_severe , sdc_therapy , multilevel , multipurpose , toilet , geographic , small_schl , new_schl , urban_sec , seismic , con_util , con_offsite , con_s_onsite , con_reconst , con_new_const , site_reloc , site_other , fin_hard , reserve , dist_contr , ar_interest , ar_match , ar_clsout , ar_other , alt_dev , site_toxic , add_grant_other , ped_safe_path , sec_sdc_non_sev , sec_sdc_severe , sec_sdc_therapy , rehab_mitigate , handicap_fire , eleve_2_stop , additional_stop ) values (new_ins.trans_date , new_ins.login_id , new_ins.new_app_prg_code , new_ins.dist_code , new_ins.new_app_attend , new_ins.new_app_project , new_ins.doc_trans_date , new_ins.trans_type new_ins.trans_seq new_ins.release_seq '123', '123', 0, 'N', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, )); Thanks in Advance Mukund