DataObjects/core.sql
[Pman.Core] / DataObjects / core_functions.sql
index 23a2cbb..d35ce1e 100644 (file)
@@ -23,11 +23,15 @@ CREATE FUNCTION core_enum_seqmax_update( in_etype varchar(128))
 
 BEGIN
         DECLARE v_seqmax INT(11);
-        SELECT MAX(seqid) +1 INTO seqmax FROM core_enum WHERE
+        SELECT MAX(seqid) +1 INTO v_seqmax FROM core_enum WHERE
             etype = in_etype;
         UPDATE core_enum SET seqmax = v_seqmax WHERE etype = in_etype;
-        RETURN seqmax;
+        RETURN v_seqmax;
     END $$
 DELIMITER ;
 
--- usage: SELECT core_enum_seqmax_update(DISTINCT(etype)) FROM core_enum;
\ No newline at end of file
+-- usage: SELECT core_enum_seqmax_update(DISTINCT(etype)) FROM core_enum;
+DROP TABLE IF EXISTS core_enum_tmp;
+CREATE TEMPORARY TABLE core_enum_tmp SELECT DISTINCT(etype) FROM core_enum;
+SELECT core_enum_seqmax_update(etype) FROM core_enum_tmp;
+DROP TABLE IF EXISTS core_enum_tmp;
\ No newline at end of file