是否有可能以某种方式为select的每一行执行一些代码而不使用游标?
在我的情况下:我有一个临时表来存储一个复杂脚本的数据.最后,我想在输出中提示该表的某些信息(受某些条件限制).
目前我正在使用带有select的游标来限制表的行.在这个游标我正在使用
print '...'
Run Code Online (Sandbox Code Playgroud)
生成输出.
必须有一种更简单的方法来做这些事情......
编辑:
create table #tmpAttributes(AttributeId uniqueidentifier, Value float, ValueString nvarchar(max), ActionId uniqueidentifier)
insert into #tmpAttributes (AttributeId, Value, ValueString, ActionId)
select ID,..... -- in this select i'm doing some value conversions, if conversion is not possible i'm using -1
insert into ActionAttribute (ActionDefinitionID, Discriminator, ID, ReferredActionID, ValueDate, ValueListID, ValueMoney, ValueString, ValueUserID)
select @defId, 'ActionAttributeMoneyEntity', NEWID(), ActionId, null, null, Value, null, null from #tmpAttributes
-- afterwards there is this cursor where I'm printint all rows where …
Run Code Online (Sandbox Code Playgroud) 我想要的是一个提供一些事件的自定义对象.例如:
var CustomObjectTextChangedEventName = 'textChanged';
var CustomObject = function () {
var _this = this;
var _text = "";
_this.OnTextChanged = document.createEvent("Event");
_this.OnTextChanged.initEvent(CustomObjectTextChangedEventName, true, false);
_this.ChangeText = function (newText) {
_text = newText;
fireTextChanged();
};
function fireTextChanged() {
_this.dispatchEvent(_this.OnTextChanged);
}
}
Run Code Online (Sandbox Code Playgroud)
使用该事件的代码如下所示:
myCustomObject = new CustomObject();
myCustomObject.addEventListener(CustomObjectTextChangedEventName, handleTextChanged, false);
Run Code Online (Sandbox Code Playgroud)
正如您所看到的......在JS中使用事件的默认方式.但我不能让它变得烦人......
目前我的问题是我的对象没有实现"addEventListener"和"dispatchEvent".但是这个功能是从"元素"正常实现的......
我可以以某种方式提供它们,还是我必须为自己实现它们?我该如何实施它们?我是否必须实施自己的事件处理?(具有处理程序的内部列表,"添加" - 和"删除" - 处理程序功能,并在我要触发事件时触发每个处理程序)
问候!