set @s = concat("SELECT TRIGGER_NAME INTO @o_tr FROM information_schema.triggers WHERE TRIGGER_SCHEMA = 'DB_Music' AND TRIGGER_NAME = '", @tr,"';");
PREPARE stmt from @s;
EXECUTE stmt;
if length(@o_tr) =0 then
set @dr_on = concat("DROP TRIGGER IF EXISTS ", @tr);
set @tr_on = concat("CREATE TRIGGER before_insert_once", @t, "
BEFORE INSERT ON once", @t, "
FOR EACH ROW
SET NEW.`ID` = replace(uuid(),'-','');");
select reverse(substr(reverse(trim(replace(group_concat(' (select * from ',table_name, ') union'),',',''))),6)) into o FROM information_schema.tables WHERE table_schema = 'DB_Music' and table_name like 'once2%';
set @o = concat("create or replace view onces as",o);
PREPARE stmt from @o;
EXECUTE stmt;
end if;
set @tr = concat('before_insert_time', @t);
set @s = concat("SELECT TRIGGER_NAME INTO @t_tr FROM information_schema.triggers WHERE TRIGGER_SCHEMA = 'DB_Music' AND TRIGGER_NAME = '", @tr,"';");
PREPARE stmt from @s;
EXECUTE stmt;
if length(@t_tr) = 0 then
set @dr_ti = concat("DROP TRIGGER IF EXISTS ", @tr);
set @tr_ti = concat("CREATE TRIGGER before_insert_time", @t, "
BEFORE INSERT ON time", @t, "
FOR EACH ROW
SET NEW.`ID` = replace(uuid(),'-','');");
select reverse(substr(reverse(trim(replace(group_concat(' (select * from ',table_name, ') union'),',',''))),6)) into t FROM information_schema.tables WHERE table_schema = 'DB_Music' and table_name like 'time2%';
set @t = concat("create or replace view times as",t);
PREPARE stmt from @t;
EXECUTE stmt;
select @dr_on as dr_on, @tr_on as tr_on, @dr_ti as dr_ti, @tr_ti as tr_ti;
下午4:12 Error Codes: MySQL Error 1295 - SQLSTATE: HY000 (ER_UNSUPPORTED_PS) This command is not supported in the prepared statement protocol yet www.briandunning.com
下午4:00 ERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet - Google 搜索 www.google.com.hk
下午3:48 ERROR 1235 (42000): This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table' - Google 搜索 www.google.com.hk
下午3:41 MySQL :: MySQL 5.0 Reference Manual :: 13.1.18 DROP TRIGGER Syntax dev.mysql.com
下午3:40 MySQL :: MySQL 5.0 Reference Manual :: 13.1.11 CREATE TRIGGER Syntax dev.mysql.com
下午2:21 完全解析MySQL数据库中Show命令用法:show tables like "%Tbl_User%"; - 向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 - Life is Short,Play it More,So Playin' with IT,Focus on Killer Application,Marketing Meets Technology.︻┳═一 Ζ〧φ﹀ヘ - www.justwinit.cn