Talk:Stored procedure

message: From the article:'
':By providing an API that implements business logic within the database using stored procedures, the need to duplicate logic within client programs is lessened or eliminated. [...].
This sounds a bit biased. The opposite is just as true. Duplication can be pushed either to the database or to the client programs, and there are arguably more effective ways to deal with it in the second case. The sentence seems to imply the case where there are many client programs that don't share anything above the database level. In this case the author is right, but this is a special case, not a general truth.
:Some critics claim that databases should be for storing data only, and that business logic should only be implemented by writing a business layer of code, through which client applications should access the data. However, the database system is intended to not only store the data but also to ensure its integrity and consistency.
"Some critics" refers to a large portion of the software development field, and probably a vast majority of software development thought leaders. The passage is an opinion and, as far as I know, not a very widely shared one.
Nitpicking:
:[...]a business layer of code, through which client applications should access the data.
The author seems to be talking about three-tier architectures. In this approach, the business layer is the core of the application, not the layer through which the application accesses data. The presence of a data layer access (for example an Object-Relational Mapper) as a subset of the business layer is not integral to the pattern - the business logics might access the data through many different means, like Active Records or Embedded SQL.
I won't modify the page right now - I'm waiting for comments.
Nusco 22:21, 15 December 2006 (UTC)
thread_title: Opinion

message: I'm adding a cleanup template the article because it looks as if it's evolved to be a bit disorganised.  I'll have a go at it in the next little while if nobody else gets there first. Izogi 19:10, 7 April 2006 (UTC)
thread_title: Adding cleanup template

message: From the article:
:The advantage of a stored procedure is that when it is run, in response to a user request, it is run directly by the database engine, which usually runs on a separate database server and is generally faster at processing database requests.
Is this correct?  It doesn't seem very clear to me.  If I submit some inline SQL to a database engine, it will still execute just as quickly (except for things like compilation), it will execute inside the database engine, and will only return the results that the SQL query requested.  I think what the author might have meant is that the result of multiple queries can be strung together inside the database engine, allowing an entire combined operation to be carried out internally without having to ferry intermediate results and further requests back and forth between database and application. Izogi 19:10, 7 April 2006 (UTC)
thread_title: "The advantage of a stored procedure"

message: * Merge and redirect UDF to here since this term is used in template - I'm not an SQL expert but it looks like two terms that are exactly the same. -- RevRagnarok Talk Contrib Reverts 11:59, 17 June 2006 (UTC)
replies: text: Stored procedures and UDFs are vastly different, and so they shouldn't be merged. -- Mikeblas 21:39, 17 June 2006 (UTC)
replies: text: I think your confusion came from a bad descrpition on the UDF page. I've edited that page and removed the merge tags. Let me know if you think it could be clearer or find any errors. I'll also some text to this article about UDFs to highlight the differences. -- Mikeblas 21:57, 17 June 2006 (UTC)
thread_title:  Merge from [[User Defined Function]] 

message: Correct me if I'm wrong, but stored procedures can't usually be vulnerable to SQL injection, which is something that should be mentioned under 'Security'.83.78.45.52 14:07, 31 August 2007 (UTC)
thread_title:  SQL Injection 

message: Might be a good idea to provide an example to illustrate the concept of an SP? As I'm not an expert I'd left it to others.  —Preceding unsigned comment added by 192.54.144.229 (talk) 10:14, 28 September 2007 (UTC)
thread_title:  Example 

message: This article should have a section about the disadvantages of stored procedures (many, as documented by a "why not stored procedure" Google search), and their alternatives (like web services that encapsulate business logic/shield database access in a reusable way).
http://www.google.co.ve/search?q=why+not+stored+procedures
--Juanco 18:51, 28 September 2007 (UTC)
thread_title: Disadvantages

message: With today's PC hardware, are SPs still pre-compiled?  Does anyone have any source to back this up?
Here are some sources that say SP are NOT pre-compiled.
Postgre http://c2.com/cgi/wiki?PostgreSql
MySQL http://www.pcwelt.de/it-profi/englishnews/Software/128397/
MS SQL Server http://msdn2.microsoft.com/en-us/library/ms190201.aspx (Note: This URL doesn't support your arguement. True SQL stores sp's as text, but when they are 1st executed they are complied & their optimised execution plan is stored in the procedure cache. 2nd & subsequent executions they are retrieved, thus saving the Query parse, Plan generation & Cost based optimisation phases. In frequenely executed queries or those with very complex execution plans, this often results in a significant CPU saving. Especially with modern Web App's that typically have a small set of very frequently executed queries. The benefits are even more pronounces where they use ORM layers like nHibernate or LINQ-to-SQL (as they typically produce very verbose queries which results in excessive network traffic.)  
Of course they only have a finite life in cache, if they are rarely executed, they eventually get discarded from cache & will need to be parsed, if they ever executed again.
)
It seems pre-compiled is a knee-jerk reaction.  
Ask what are the advantages of SP and first response is pre-compiled but it would seem SP was never pre-compiled in many database systems.
Does anyone know which db provide pre-compiled SP from a reliable source (preferrably from the db vendors)?  NYCDA (talk) 23:04, 10 December 2007 (UTC)
thread_title:  Unreferenced Tag - Pre-Compiled SP