I have written a cursor:
DECLARE CURSOR_SendMail CURSOR FAST_FORWARD
FOR
SELECT AlertId,AlertDetailsId,AlertDescription
,AlertTarget,ProjectDetailId,Subject
FROM tblAlert
WHERE AlertId > @MaxAlertID
Here @MaxAlertID is some id so that records above that id will be mailed.
What I want to ask is:
While fetching records one-by-one and mailing them, will any new record inserted in tblAlert table also be considered or just the records that were available while declaring the cursor.
e.g.
At the time of declaring cursor max id present in table is 1000 and @MaxAlertID is 0.
So when I start sending mail for each record from 1 and above and I reach at some record 517 and a couple of records get added to tblAlert with 1001 and 1002, so those 1001,1002 will be considered or just up-to 1000 will be considered.
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
STATICorKEYSET. If you do want to consider new records, specifyDYNAMIC.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.