mysql:16093
From: ¥µ¥«¥ª¥·¥¹¥Æ¥à³«È¯ ºäÈøÎÉÆó <¥µ¥«¥ª¥·¥¹¥Æ¥à³«È¯ ºäÈøÎÉÆó <sakao@xxxxxxxxxx>>
Date: Sat, 22 Feb 2014 19:33:22 +0900
Subject: [mysql 16093] function¤Çupdate¤¬¹¹¿·¤µ¤ì¤Ê¤¤
ºäÈø¡÷£Ó£Ó£Ä¤Ç¤¹¡£ °Ê²¼¤Î¤è¤¦¤ÊºÎÈÖ¤¹¤ë function ¤òºîÀ®¤·¤Þ¤·¤¿¡£ MySQL Workbench Åù¤Ç¼Â¹Ô¤¹¤ë¤ÈÀµ¤·¤¯ºÎÈÖ¤·¤Æ¤¯¤ì¤Þ¤¹¤¬ CakePHP ¥×¥í¥°¥é¥àÆâ¤ÇϢ³¤·¤Æ¼Â¹Ô¤¹¤ë¤È¡¢ºÇ½é¤·¤«ºÎÈÖ ¤·¤Æ¤¯¤ì¤Þ¤»¤ó¡ÊϢ³¤·¤Æ10²ó¼Â¹Ô¤·¤Æ¤â¡¢ºÇ½é¤Î1²ó¤Î¤ß¡Ë¡£ MySQL¤Ï½é¿´¼Ô¤Ç¤¹¡¢²¿¤¬¤¤¤±¤Ê¤¤¤Î¤Ç¤·¤ç¤¦¤«¡© ¥Ð¡¼¥¸¥ç¥ó¤Ï5.3 ¤Ç¤¹¡£ ------------------------------------------------ create function funcMakeId(intKubun int) returns int begin declare intId int; declare intMin int; declare intMax int; declare continue handler for NOT FOUND begin set intId = -1; end; select numbering_id, numbering_from, numbering_to into intId, intMin, intMax from tb_id_numbering where numbering_type = intKubun for update; if (intId < 0) then return -1; end if; if (intId >= intMax) then set intId = intMin; else set intId = intId + 1; end if; update tb_id_numbering set numbering_id=intId where numbering_type = intKubun; return intId; end ----------------------------
-> 16093 2014-02-22 19:33 [¥µ¥«¥ª¥·¥¹¥Æ¥à³«È¯ º] function¤Çupdate¤¬¹¹¿·¤µ¤ì¤Ê¤¤ 16094 2014-02-22 22:57 ¨±[¥µ¥«¥ª¥·¥¹¥Æ¥à³«È¯ º]