通过存储过程 创建动态触发器

STM32F103ZET6驱动57闭环步进电机(连线+代码) 一、设备: 1. STM32F103开发板 (普中F103的板子) 2. 57闭环电机带驱动 3. 24V/3A的直流电源,用于给电机驱动供电 简单说明:使用Keil5编程,主要使用了PWM波,外部中断和时间中断,按键控制电机使能和脱机并且控制PWM的周期,调节周期即调节电机的转速。 二、STM32开发板与电机驱动的连线: 1.PUL-、ENA-、DIR-与STM32的连接方法: 可以参考CSND的这个链接中的说明,使用共阴极接法:STM32F407-用TB6600驱动器驱动57步进电机(代码 阅读详情
/*
Author		:Bean
Create date	:2011-08-12
问题描述1   :很多时候我们一个模板会有很多的表格,例如Care 项目,一共有29张表,想删除一条单据,
			  那么我们要写29条Delete语句
问题描述2	:如果不写触发器,很多时候只是_1表的数据被删除了,剩下的_2,_3,_4...表的数据还会存在数据库里浪费资源
功能描述	:主要用于Landa数据库单据删除,当删除_1表后,后面带动的_2,_3,_4...表相同VGUID的单据会被自动删除
优点		:快捷,方便
使用案例	:Exec Porc_AddTrigger '表名_1'   
*/

if OBJECT_ID('Porc_AddTrigger','P') is not null  drop proc Porc_AddTrigger
go
create Proc Porc_AddTrigger
@TB_name varchar(50)
as
Begin
	Begin Transaction
	Begin Try
		if RIGHT(@TB_name,2)!='_1'
			RaisError('Table name should end with "_1"',16,1)
		Else
		Begin
			declare 
					@sql varchar(max)
			set @sql='
			create trigger TR_'+left(@TB_name,LEN(@TB_name)-2)+'
			on '+@TB_name+'
			for delete
			as
			Begin
				declare @TMP varchar(50),
						@i numeric(38,0),
						@table varchar(50),                
						@SQL varchar(max),
						@VGUID uniqueidentifier
					set @TMP='+''''+left(@TB_name,len(@TB_name)-1)+''''+'
					set @table=''CSEMPL_2''
					set @VGUID=newid()
					set @i=2
				select @VGUID=VGUID from deleted
				while 1=1
				Begin  
					set @table=@TMP+convert(varchar(10),@i) 
					if OBJECT_ID(@table,''U'') is not null 
					Begin   
						set @SQL=''delete from '' + @table +'' where VGUID ='''+'+''''''''+'+' convert(varchar(50),@VGUID)+'+''''''''''+'
						exec(@SQL)
						set @i=@i+1   
					End Else
						Break;   
				end
			End'
			Exec(@sql)
		End
		Commit Transaction
	End Try
	Begin Catch
		Rollback Transaction
		declare @Error_Message varchar(1000)
		set @Error_Message= 'Error_Nuber  :'+CONVERT(varchar(5),Error_Number())+char(13)+
							'Error_Line   :'+Convert(varchar(5),Error_Line())+char(13)+
							'Error_Message:'+CONVERT(varchar(50),Error_Message())
		RaisError(@Error_message,16,1)		
	End Catch	
End


 

BACnet协议栈基本对象BI、BO、AI、AO、AV以及device和File对象介绍 阅读详情

相关推荐

以ATT&CK为例构建网络安全知识图

随着攻击工具、方法的逐渐升级和复杂化,安全数据的大规模融合,攻防对抗愈加激烈。安全团队如何在浩瀚数据中有效发现高级威胁的蛛丝马迹,如何把网络安全专家的经验、知识有效转化为可复制可扩展的数据分析能力,如何将对抗高级威胁的“炼金术”逐步升级为科学淘金指南,如何将安全从业者从繁重的体力劳动中解放出来,愈发成为安全能力亟需突破的难点和重点,也是我们正在探索的方向。正如医疗行业中治疗疑难杂症依赖医疗专家,网络空间高级威胁的防护和处置也依赖安全专家的经验与知识。

2401_88752684的博客 1092

mysql 存储过程中能动态创建触发器吗_可以在存储过程中使用动态SQL创建MySQL触发器吗?...

是否可以在存储过程中使用动态生成的SQL在MySQL中创建触发器?我正在通过准备语句在我的过程中执行其他动态构造的查询,但是当我尝试相同的方法来创建触发器时,我得到以下错误:ERROR Code: 1295This command is not supported in the prepared statement protocol yet这个问题有解决方法吗?是否有另一种使用动态SQL创建触发器...

weixin_42663213的博客 704

IEC 62056协议栈深度拆解:从物理层握手到应用层AARQ,一次完整的DLMS通讯抓包分析

本文深入解析IEC 62056协议栈(DLMS/COSEM)的全流程通信机制,从物理层握手到应用层AARQ建立,提供详细的抓包分析和实战指南。涵盖RS-485配置、HDLC帧解析、OBIS编码解读等核心内容,并附有常见故障排查技巧,助力开发者高效实现电能表数据采集。

weixin_29182481的博客 313

SQL Server触发器创建、删除、修改、查看

教程贴士:本教程为大家介绍SQL Server触发器创建、删除、修改、查看方法。   一:触发器是一种特殊的存储过程,它不能被显式地调用,而是在往表中插入记录﹑更新记录或者删除记录时被自动地激活。所以触发器可以用来实现对表实施复杂的完整性约束。   二:SQL Server为每个触发器都创建了两个专用表:Inserted表和Deleted表。这两个表由系统来维护,它们存在于内存中而

tianwailaibin的专栏 7万+

在Pycharm中配置Pyqt5工具(2023年新版教程)

在Pycharm中配置Pyqt5相关的三个工具:QtDesigner、PyUIC、PYRCC

网络技术和Python 2万+

幸狐RV1106开发板实战:5分钟搞定Yolo8模型部署(附避坑指南)

本文详细介绍了在幸狐RV1106开发板上快速部署YOLOv8模型的实战流程。通过RKNN-Toolkit2工具链,将ONNX模型转换为RV1106 NPU专用的RKNN格式,并完成交叉编译与上板运行。文章重点分享了环境搭建、模型转换的关键步骤以及常见的避坑指南,帮助开发者高效实现边缘AI目标检测应用。

weixin_28677451的博客 916

利用存储过程动态创建表及基于该表的触发器

--利用存储过程动态创建表及基于该表的触发器 --1、授权 grant create any sequence to scott; grant create any sequence to scott; grant select any sequence to scott; grant create any trigger to scott; --2、存储过程 c

sych888的专栏 1447

GFPS技术原理(一)-简介

GFPS(谷歌快速配对服务)利用BLE技术简化设备配对流程,相比传统方式大幅提升用户体验。首次配对时,设备广播包含型号ID和安全密钥的BLE信号,手机检测后弹出配对通知,用户点击即可完成安全连接并将设备与Google账户绑定。该技术支持跨设备同步、电量显示、找回设备等功能,后续配对更加便捷。GFPS通过BLE实现快速发现、一键配对和安全连接,结合Google后端服务提供元数据支持,已成为出海设备的认证标准。其核心优势在于简化操作步骤并增强功能性,特别适合非技术用户群体。

十多年蓝牙协议软件开发,擅长蓝牙协议分析 2062

SQL动态创建触发器

IF NOT EXISTS ( SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'delpoints') AND OBJECTPROPERTY(OBJECT_ID('delpoints'), N'IsTrigger') = 1 )...

PErryiii的博客 428

PCL点云算法与项目实战案例汇总(长期更新)

本专栏将深入探讨PCL(点云库)的基础算法,旨在帮助读者掌握点云处理的核心技术。内容涵盖点云的采样、过滤、配准、分割等基础操作,并结合实际案例,展示这些算法在工程中的应用。无论你是初学者还是有一定经验的开发者,都能通过本专栏加深对PCL的理解,提升在三维数据处理领域的技能。

纵马踏花向自由 3008

如何在 SAP Server Side JavaScript 里消费 destination

在SAP云平台里打开SAP HANA Web-Based Development Workbench进行服务器端JavaScript的开发。 创建一个新的package: 创建一个新的application: 创建一个新的文件google-distance-api.xshttpdest用于维护destination相关信息: host = "maps.googlea...

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 616

mysql动态创建触发器_在存储过程中创建MySQL动态触发器

I want to create the dynamic trigger when call the procedure, it give the mysql server version syntax error, when i select that query and execute in separate query editor it will be executed.DROP TABL...

weixin_39611506的博客 343

机床联网系列总结

总结机床联网专栏,两个好用的工具介绍,以及后续提升的方法和建议。

若云流风的专栏 936

mysql动态创建触发器,在存储过程中创建MySQL动态触发器

I want to create the dynamic trigger when call the procedure, it give the mysql server version syntax error, when i select that query and execute in separate query editor it will be executed.DROP TABL...

weixin_36427631的博客 393

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

mysql 存储过程中能动态创建触发器吗_mysql – 从Trigger调用包含动态SQL的存储过程...

我从Trigger调用存储过程,我收到以下错误:Dynamic SQL is not allowed in stored function or trigger为什么会发生这种情况,动态SQL正在存储过程中执行,该过程从触发器调用.也许这就是问题,如果有的话有什么办法吗?编辑(添加代码):这是主表中的Trigger:-- Trigger DDL StatementsDELIMITER $$USE ...

weixin_30147611的博客 407

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

mysql触发器能使用动态sql,是否可以在存储过程中使用动态SQL创建MySQL触发器?...

Is it possible to create a trigger in MySQL using dynamically generated SQL from within a stored procedure? I am executing other dynamically constructed queries in my procedure by preparing a statemen...

weixin_39559369的博客 616

MySQL之视图、存储过程、触发器、函数、事务、动态执行SQL

视图视图是一个虚拟表(非真实存在),其本质是【根据SQL语句获取动态的数据集,并为其命名】,用户使用时只需使用【名称】即可获取结果集,并可以将其当作表来使用。创建视图:createviewv1as select*fromstudentwhereid>100;今后可以直接通过:select*fromv1;#直接访问学生ID大于100的信息删...

weixin_34018202的博客 159

go 动态创建mysql表_Sql语句不能识别Go的解决办法(动态创建表的触发器)

问题来源用sqlserver直接打开sql文本,执行没问题,但是当用Sqlcommand类执行cmdtext命令文本时总是失败报错。原因分析及解决用数据库直接执行sql语句没问题,甚至还可以用Go来进行分批处理,但是当你用链接类访问数据库,并执行sql语句时就有些限制,如下:System.Data.SqlClient.SqlCommand cmd;try{using (System.Data.Sq...

weixin_39593593的博客 588

【MySQL速通篇003】MySQL视图,MySQL触发器,MySQL函数,MySQL存储过程(参数分类,存储过程的增删改查等),SQL的动态执行,支持事务的存储过程,pymysql

MySQL视图,MySQL触发器,MySQL函数,MySQL存储过程(参数分类,存储过程的增删改查等),SQL的动态执行,支持事务的存储过程,pymysql

周周の博客小屋 1888

掌握包、类、触发器、函数、存储过程的 创建以及应用,掌握 DMSQL 程序的基本操作:语句块操作、 游标访问,动态sql执行

包 包创建 create table tab_new_package (id int, name varchar(100), city varchar(100)); insert into tab_new_package values(1,‘wuhan’,‘武汉’); create or replace package new_package is exception1 exception; count int; pcur cursor; procedure addcs(pname varchar(100)

qq_44956461的博客 610

存储过程

基本语法: create or replace procedure create_businesscgdmx(year in varchar2) Authid Current_User as // 红:参数 蓝:当前用户 v_tab_sl number; //声明变量 yycgdmx varchar2(100); yycgd va...

weixin_30333885的博客 92

mysql8.0中触发器(支持游标,以及间接支持动态sql)的详细使用

14.触发器使用管理 14.1创建相关的数据库以及创建两张表,并向表中插入若干条数据 创建数据库mydatabase,创建表products、vendors 14.2创建查看触发器:创建触发器,查看触发器的信息。编写其中一张表的sql语句,激活触发器,查看另一张表的数据信息是否改变。一个表中支持的触发器类型如下: insert之前/之后,可以引用一个名为NEW的虚拟表,访问被插入的行 delete之前/之后,可以引用一个名为OLD的虚拟表,访问被删除的行 ...

qq_38390669的博客 1271

Oracle存储过程汇总

开场来一发本次举例的脚本: --创建mq表 create table t_commodity_frozen_test(id int primary key,commodity_id int,province varchar2(20),create_time date,status integer default 0); -------------------------------------...

布偶猫爸爸的博客 2612

Oracle创建触发器详解及例子

触发器详解 1。触发器与触发该触发器的SQL语句同属于一个事务,触发器不允许发出任何事务控制语句,如 commit、rollback、savepoint或者set transaction,它只能随着外部事务的提交、回滚而提交、回滚。(但在oracle8i 以及更高的版本中,你可以创建作为自治事务而执行的触发器,在这种情况下,触发器可以做提交或回滚操作,而与触发该触发器的外部SQL所在的事务无关)

冷夜轩的博客 1万+

mysql 存储过程 after_mysql存储过程实例

delimiter ||-- after INSERT 触发器drop TRIGGER if EXISTS insert1after2;create trigger insert1after2 after INSERT on tab1 for each rowbegininsert into tab2(id, username) values(new.id,new.username);end||d...

weixin_31688873的博客 201

mysql触发器执行动态语句_关于MySQL中触发器执行动态sql的问题

这几天手头开发的系统要做一个类似windows账户到期时间的功能,考虑了半天想出了一个技术上和逻辑上都还能实现的解决方案:创建一个用户存入数据库的时候都创建一个事件调度器来控制用户的到期时间(mysql的时间调度器确实很方便)。想起来是很简单,但是做起来问题确实一波接一波...一些小问题就不说了,到了关键的地方了:在插入一个用户的时候我到底是在应用层来添加一个事件调度器呢还是在数据库里面自动添加。...

weixin_36369848的博客 550
上一篇: 删除表1,其他表自动删除
下一篇: 递归 查询部门及子部门
bean_sql
博客等级 码龄16年 55粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值