因爲初期規劃很差,項目管理的action都存入到數據庫中了,而實際上應該以配置文件的形式保存的,因此如今想改過來。一條條複製是不可能的,幾百條記錄,能夠用java編寫個小程序或者其餘語言編寫個腳原本實現,都很簡單,但由於這兩天在學存儲過程,因此就試着寫一個了(數據庫的過程、函數和觸發器等真的很好玩啊!)。 (select max(I_ID) from p_link group by C_ACTION); sql
repeat小程序 fetch c_cursor into tmp_action,tmp_power;函數 if not i_done thenfetch set c_content = concat(c_content, tmp_action, '=', tmp_power, char(13));spa end if;code until i_done end repeat;ci 最終可獲得一行行結構爲 XXX=XXX 鍵值對。項目管理 |
drop procedure if exists get_all_links; delimiter $$ create procedure get_all_links() begin declare c_content text; declare i_done int default 0; declare tmp_action varchar(100); declare tmp_power tinyint; declare c_cursor cursor for select C_ACTION,B_POWER from p_link where I_ID in (select max(I_ID) from p_link group by C_ACTION); declare continue handler for sqlstate '02000' set i_done = 1; open c_cursor; set c_content = ''; repeat fetch c_cursor into tmp_action,tmp_power; if not i_done then set c_content = concat(c_content, tmp_action, '=', tmp_power, char(13)); end if; until i_done end repeat; close c_cursor; select c_content into outfile 'D:\\action.properties'; end $$ delimiter ; call get_all_links(); drop procedure get_all_links;