TSQL Cursor new record added

不想你离开。 提交于 2019-12-01 18:39:27

Look at the documentation for DECLARE CURSOR. There are options you can specify so that you get the behaviour you want - which you haven't told us.

If you don't want to consider new records, consider specifying STATIC or KEYSET. If you do want to consider new records, specify DYNAMIC.

I can't actually remember what the default behaviour is - and can't seem to find it at the moment. If I needed specific behaviour, I'd always specify it rather than rely on the default.

The default is Dynamic, unless you have changed it.

To quote from the documentation:

DYNAMIC

Defines a cursor that reflects all data changes made to the rows in its result set as you scroll around the cursor. The data values, order, and membership of the rows can change on each fetch. The ABSOLUTE fetch option is not supported with dynamic cursors.

So adding DYNAMIC to your cursor definition will give you what you want. Or do you need the opposite? Then make a STATIC cursor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!