MySql存储过程一例
DROP PROCEDURE IF EXISTS saveorupdate_sub_key_proc; CREATE PROCEDURE saveorupdate_sub_key_proc( IN sub_id_arg int(4), IN english_arg varchar(500), IN hindi_arg varchar(500), IN marathi_arg varchar(500), IN tamil_arg varchar(500) ) BEGIN DECLARE count_sub_item INT(4); select count(*) into count_sub_item from subject_keywords where sub_id = sub_id_arg; if count_sub_item > 0 THEN update subject_keywords set english = english_arg,hindi = hindi_arg,marathi = marathi_arg,tamil = tamil_arg where sub_id = sub_id_arg ; ELSE insert into subject_keywords(sub_id,english,hindi,marathi,tamil) values(sub_id_arg,english_arg,hindi_arg,marathi_arg,tamil_arg); end if; select count_sub_item; END; call saveorupdate_sub_key_proc(412,'12','aa','cc','dd');