mysql触发器不支持动态sql

本文讨论了MySQL触发器不支持动态SQL的限制,通过展示大量的IF-ELSE语句插入不同表的示例,揭示了当@pointid变化时,如何在触发器中针对不同表进行操作的问题,强调了这种做法在实际应用中的局限性。
摘要由CSDN通过智能技术生成

elseif @pointid=93

then

insert into point_93 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=94

then

insert into point_94 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=95

then

insert into point_95 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=96

then

insert into point_96 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=97

then

insert into point_97 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=98

then

insert into point_98 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=99

then

insert into point_99 (sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=100

then

insert into point_100(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=101

then

insert into point_101(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=102

then

insert into point_102(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=103

then

insert into point_103(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=104

then

insert into point_104(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=105

then

insert into point_105(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=106

then

insert into point_106(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=107

then

insert into point_107(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=108

then

insert into point_108(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=109

then

insert into point_109(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=110

then

insert into point_110(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=111

then

insert into point_111(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=112

then

insert into point_112(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=113

then

insert into point_113(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=114

then

insert into point_114(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=115

then

insert into point_115(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=116

then

insert into point_116(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=117

then

insert into point_117(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=118

then

insert into point_118(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=119

then

insert into point_119(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=120

then

insert into point_120(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=121

then

insert into point_121(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=122

then

insert into point_122(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=123

then

insert into point_123(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=124

then

insert into point_124(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=125

then

insert into point_125(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=126

then

insert into point_126(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=127

then

insert into point_127(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=128

then

insert into point_128(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=129

then

insert into point_129(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=130

then

insert into point_130(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=131

then

insert into point_131(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=132

then

insert into point_132(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=133

then

insert into point_133(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=134

then

insert into point_134(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=135

then

insert into point_135(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=136

then

insert into point_136(sqtname,value,datetime,date,time) values(new.sqtname,new.value,new.datetime,DATE_FORMAT( new.datetime, ‘%Y-%m-%d’),DATE_FORMAT( new.datetime, ‘%h:%i:%s’));

elseif @pointid=137

t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值