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,715 of 19,505   
   Erland Sommarskog to phdate   
   Re: Number generator   
   11 Dec 09 22:42:14   
   
   From: esquel@sommarskog.se   
      
   phdate (drscrypt@gmail.com) writes:   
   > Over the last couple of days, I have tried lots of ways to generate   
   > sequential numbers within a user defined function, including a stored   
   > proc to compute the next number and a function to return it.  (I need   
   > this ability as part of a larger scientific package, and it needs to be   
   > a function).  I get errors similar to this:   
   >   
   > "Only functions and extended stored procedures can be executed from   
   > within a function."   
   >   
   > Here is the latest non-working code I have after many changes.  In   
   > essence, each time I call num_gen() function, I would like a new number   
   > to be returned, and which can be used from other functions:   
      
   A user-defined function cannot change state, so you are on the wrong   
   track entirely.   
      
   Since you say "it needs to be a function", I am not going to show   
   you any code now. You first have to back and change that requirement.   
      
      
   --   
   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   
   SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx   
      
   --- 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