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 17,898 of 19,505   
   Lennart Jonsson to Erland Sommarskog   
   Re: A CTE Question   
   29 Aug 10 15:24:13   
   
   From: erik.lennart.jonsson@gmail.com   
      
   On 2010-08-29 13:44, Erland Sommarskog wrote:   
   [...]   
   >   
   > One final question: all you DB2 guys have this condition   
   >   
   >    where iter < 1000   
   >   
   > in the recursive part of the CTE. Is this standard on DB2 to protect   
   > against cycles? What happens if you don't include it, and there is a   
   > cycle? Does the query loop forever? On SQL Server the default is that   
   > if there is more than 100 levels of recursion, you get an error. You   
   > can override this with a query hint.   
   >   
      
   On db2 there is no default limit and the query will loop forever (well   
   until terminated, runs out of memory, etc).   
      
   Beside protecting from infinite recursion, the compiler will produce a   
   warning unless it can deduce that the query is guaranteed to terminate:   
      
   SQL0347W  The recursive common table expression "LELLE.TC" may contain   
   an infinite loop.  SQLSTATE=01605   
      
   A trivial termination condition like: iter < 1000   
      
   helps the compiler to realise that the recursion will terminate, and   
   prevents this warning.   
      
   [...]   
      
   > Tja, själv tycker jag som skåning att allt norr om Loshult är Lappland,   
   > så jag kan förstå om Ume-bor tycker att allt så där långt söderut är samma   
   > sak som Tyskland. :-)   
   >   
      
   -)   
      
   /Lennart   
      
   --- 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