本文介绍了我创建sql触发器,但它显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请检查我的触发器代码
please check my trigger code
SET @priority = (SELECT dbo.Jobs.ProcessStatus FROM dbo.Jobs WHERE dbo.Jobs.ProcessStatus = @NotificationTypeID); IF(@priority = 1) Begin SET @NotificationTypeID = 1; SET @NotificationType='Normal'; End ELSE IF(@priority = 2) Begin SET @NotificationTypeID = 2; SET @NotificationType='Critical'; END推荐答案
如果你愿意的话会有所帮助发布您遇到的错误但是... 根据您提供的代码,您很可能遇到查询尝试将多行提取到单个变量中的问题。这一个 It would really help if you would post the error you encountered but... Based on the code you provided you most likely encounter a problem that your query tries to fetch multiple rows into a single variable. This one SET @priority = (SELECT dbo.Jobs.ProcessStatus FROM dbo.Jobs WHERE dbo.Jobs.ProcessStatus = @NotificationTypeID);
如果这是真的,你几乎没有选择: - 确保通过修改条件只选择一行 - 使用游标创建循环,处理所有返回的行 - 而不是游标使用单个语句在数据库中进行修改(如果你正在修改数据) 如果错误有所不同,请发布完整描述。
If that's true you have few choices: - ensure that you select only one row by modifying the conditions - create a loop using a cursor where you handle all the returned rows - instead of cursor use a single statement to make modifications in the database (if you're modifying the data) If the error is something different, please post the full description.
更多推荐
我创建sql触发器,但它显示错误
发布评论