home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,535 of 19,505   
   Erland Sommarskog to Travis Crow   
   Re: Cursor Question   
   02 Dec 11 12:35:43   
   
   From: esquel@sommarskog.se   
      
   Travis Crow (noreply@invalid.org) writes:   
   > If I declare a cursor with a "where clause", is that "where clause"   
   > evaluated when I declare the cursor or when I open it?   
      
   It depends on the type of cursor. There are four types: DYNAMIC, KEYSET,   
   STATIC and FAST_FORWARD.   
      
   If you have a dynamic cursor, the query is essentially evaluated each time   
   you do FETCH. That is, rows that are added to the table while the cursor is   
   running will be visible.   
      
   With a static cursor, the result set of the cursor is saved to a temp   
   table and the rows are served from this table. I believe this happens at   
   OPEN time, but you could easily test to find out.   
      
   With a keyset cursor, only the keys are saved to the table, and remaining   
   rows are read from the real table at FETCH.   
      
   With FAST_FORWARD, I don't even know what happens.   
      
   I strongly recommend to stick with STATIC cursors.   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca