mysql:16094
From: サカオシステム開発 坂尾良二 <サカオシステム開発 坂尾良二 <sakao@xxxxxxxxxx>>
Date: Sat, 22 Feb 2014 22:57:56 +0900
Subject: [mysql 16094] Re: functionでupdateが更新されない
坂尾@SSDです。 自己解決いたしました。 CakePHP のキャッシュが原因でした。 キャッシュをオフしたら、正しく動きました。 > 以下のような採番する 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 ┗[サカオシステム開発 �]