fix #8131 - chinese translations
[Pman.Core] / mysql / core_enum_seqmax_update.sql
1
2 -- fixes sequencing..
3
4 DROP FUNCTION IF EXISTS core_enum_seqmax_update;
5 DELIMITER $$
6 CREATE FUNCTION core_enum_seqmax_update( in_etype varchar(128))
7         RETURNS INT(11) DETERMINISTIC
8
9 BEGIN
10         DECLARE v_seqmax INT(11);
11         SELECT MAX(seqid) +1 INTO v_seqmax FROM core_enum WHERE
12             etype = in_etype;
13         UPDATE core_enum SET seqmax = v_seqmax WHERE etype = in_etype;
14         RETURN v_seqmax;
15     END $$
16 DELIMITER ;
17
18
19
20
21
22 -- usage: SELECT core_enum_seqmax_update(DISTINCT(etype)) FROM core_enum;
23 DROP TABLE IF EXISTS core_enum_tmp;
24 CREATE TEMPORARY TABLE core_enum_tmp SELECT DISTINCT(etype) FROM core_enum;
25 SELECT core_enum_seqmax_update(etype) FROM core_enum_tmp;
26 DROP TABLE IF EXISTS core_enum_tmp;